From 8b7155b2841340c76450c46e9ebea0370cec7292 Mon Sep 17 00:00:00 2001 From: douglascdev Date: Thu, 21 Mar 2024 19:33:03 -0300 Subject: [PATCH] Scroll down after loading messages from history(#51) --- hasherino/__main__.py | 3 +++ hasherino/components/tabs.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hasherino/__main__.py b/hasherino/__main__.py index 574fd83..75ccc70 100644 --- a/hasherino/__main__.py +++ b/hasherino/__main__.py @@ -196,6 +196,7 @@ async def join_chat_click(_): return await self.tabs.add_tab(channel.value, self.message_received) + await self.chat_container.chat.scroll_to_async(offset=-1, duration=10) await self.persistent_storage.set("channel", channel.value) self.page.dialog.open = False @@ -266,6 +267,7 @@ async def run(self): self.tabs = Tabs(self.memory_storage, self.persistent_storage) self.chat_container_on_msg = chat_container.on_message + self.chat_container = chat_container # Add everything to the page await self.page.add_async( @@ -311,6 +313,7 @@ async def run(self): if channel: await self.tabs.add_tab(channel, self.message_received) + await self.chat_container.chat.scroll_to_async(offset=-1, duration=10) await self.memory_storage.set( "ttv_badges", diff --git a/hasherino/components/tabs.py b/hasherino/components/tabs.py index 2c4140b..3211a9c 100644 --- a/hasherino/components/tabs.py +++ b/hasherino/components/tabs.py @@ -139,7 +139,7 @@ async def add_tab(self, channel: str, message_received: Awaitable[ParsedMessage] channel, self.persistent_storage, self.memory_storage, message_received ) await tab.load_emotes() - asyncio.ensure_future(tab.load_history()) + await tab.load_history() close_button = ft.IconButton(icon=ft.icons.CLOSE, on_click=self.close) close_button.parent_tab = tab tab.tab_content.controls.append(close_button)