diff --git a/web/src/message_fetch.ts b/web/src/message_fetch.ts index d9f58383ed..b6b1fae7fc 100644 --- a/web/src/message_fetch.ts +++ b/web/src/message_fetch.ts @@ -17,6 +17,7 @@ import type {MessageListData} from "./message_list_data.ts"; import * as message_lists from "./message_lists.ts"; import {raw_message_schema} from "./message_store.ts"; import * as message_util from "./message_util.ts"; +import * as message_viewport from "./message_viewport.ts"; import * as narrow_banner from "./narrow_banner.ts"; import {page_params} from "./page_params.ts"; import * as people from "./people.ts"; @@ -176,7 +177,7 @@ function process_result(data: MessageFetchResponse, opts: MessageFetchOptions): // the messages we requested, and all of them are in muted // topics, but there are older messages for this stream that // we need to ask the server for. - message_lists.current.visibly_empty() + (message_lists.current.visibly_empty() || !message_viewport.can_scroll()) ) { const looking_for_new_msgs = opts.num_after > 0; const looking_for_old_msgs = opts.num_before > 0; diff --git a/web/src/message_viewport.ts b/web/src/message_viewport.ts index c921242e10..f534169319 100644 --- a/web/src/message_viewport.ts +++ b/web/src/message_viewport.ts @@ -542,6 +542,11 @@ export function maybe_scroll_to_selected(): void { } } +export function can_scroll(): boolean { + const full_height = util.the($scroll_container).scrollHeight; + return full_height > window.innerHeight; +} + export function initialize(): void { // This handler must be placed before all resize handlers in our application $(window).on("resize", () => {