# Fix: Download notification does not scroll to the currently downloading gallery修复点击下载通知不会滚动到当前正在下载的画廊 - #2994
Open
SauronSkywalker wants to merge 1 commit into
Open
Conversation
revonateB0T
reviewed
Jul 5, 2026
FooIbar
reviewed
Jul 7, 2026
SauronSkywalker
force-pushed
the
source-20260703-142148
branch
from
July 9, 2026 14:51
5ba71ba to
5ebfb07
Compare
FooIbar
reviewed
Jul 10, 2026
| navigator.navigate(DownloadsScreenDestination) | ||
| val gid = args.getLong(DownloadService.KEY_GID, -1L) | ||
| navigator.navigate(DownloadsScreenDestination(gid)) { | ||
| popUpTo(navItems.first().first) { |
| val gridState = rememberLazyStaggeredGridState() | ||
|
|
||
| LaunchedEffect(scrollToGid) { | ||
| if (scrollToGid == -1L) return@LaunchedEffect |
| LaunchedEffect(scrollToGid) { | ||
| if (scrollToGid == -1L) return@LaunchedEffect | ||
| snapshotFlow { isLoading }.first { !it } | ||
| delay(300) |
| snapshotFlow { isLoading }.first { !it } | ||
| delay(300) | ||
| val index = list.indexOfFirst { it.gid == scrollToGid } | ||
| if (index >= 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Download notification does not scroll to the currently downloading gallery / 修复:下载通知不滚动到正在下载的画廊
Summary / 概述
EN: When tapping the download notification in the system notification bar while multiple galleries are being downloaded sequentially, the app opens the Downloads screen but stays at the very top instead of scrolling to the position of the currently downloading gallery. This PR fixes the issue by passing the gallery ID (gid) as a route argument to
DownloadsScreen, which then auto-scrolls to that item on load.中: 当多个画廊按顺序下载时,点击系统通知栏中的下载通知,App 会打开下载页面但停留在列表顶部,不会自动滚动到当前正在下载的画廊位置。本 PR 通过将画廊 ID(gid)作为 route 参数传递给
DownloadsScreen,使其在加载后自动滚动到对应条目。Root cause / 根因分析
EN: The notification handler in
MainActivityreceived the gallery ID (KEY_GID) inside the notification'sBundle, but it was completely ignored — the code just callednavigator.navigate(DownloadsScreenDestination)without passing any data.DownloadsScreenhad no mechanism to know which item to scroll to.中:
MainActivity中的通知处理器在通知的Bundle中收到了画廊 ID(KEY_GID),但完全忽略了它——代码只是调用了navigator.navigate(DownloadsScreenDestination)而没有传递任何数据。DownloadsScreen没有任何方式知道要滚动到哪个条目。Changes / 代码改动
1.
MainActivity.kt— Pass gid as route arg + popUpTo / 传递 gid 作为路由参数 + 清除旧页面Triple(DownloadsScreenDestination, ...)Triple(DownloadsScreenDestination(), ...)navigator.navigate(DownloadsScreenDestination)popUpToelse -> DownloadsScreenDestinationelse -> DownloadsScreenDestination()EN: The navigation drawer entry and start destination now use
DownloadsScreenDestination()with parentheses because the addedscrollToGid: Long = -1Lparameter changes the generated class fromobjecttodata class.中: 导航抽屉条目和启动目标现在使用带括号的
DownloadsScreenDestination(),因为新增的scrollToGid: Long = -1L参数将生成的类从object变为data class。EN:
popUpTo(navItems.first().first)pops all destinations above the home page before navigating, ensuring oldDownloadsScreeninstances don't pile up. Since pop and navigate are within a singlenavigate()call, the transition is seamless with no flicker.中:
popUpTo(navItems.first().first)在导航前弹出首页之上的所有目的地,确保旧的DownloadsScreen实例不会堆积。由于弹出和导航在同一个navigate()调用中,过渡动画无缝无闪烁。2.
DownloadsScreen.kt— Accept gid via route arg + auto-scroll / 通过路由参数接收 gid + 自动滚动Function signature / 函数签名
New imports / 新增导入
EN:
LazyStaggeredGridStateandrememberLazyStaggeredGridStateare required for controlling the grid view's scroll state.snapshotFlowconverts Compose state into a Flow for reactive waiting.中:
LazyStaggeredGridState和rememberLazyStaggeredGridState用于控制网格视图的滚动状态。snapshotFlow将 Compose 状态转换为 Flow 进行响应式等待。Scroll states / 滚动状态
EN: Two separate state objects are created because the list and grid views use different state types. They are passed to the respective views so scrolling can be controlled programmatically.
中: 创建两个独立的状态对象,因为列表和网格视图使用不同的状态类型。它们被传递给各自的视图,以便以编程方式控制滚动。
Auto-scroll logic / 自动滚动逻辑
Files changed / 改动文件统计
MainActivity.ktpopUpTo+()refsDownloadsScreen.ktscrollToGidparam + scroll states + auto-scrollLaunchedEffectEN: No changes to
DownloadManager.kt,ci.yml, or any other files. The fix is fully contained in two files and follows standard compose-destinations route args pattern, consistent withGalleryCommentsScreen(gid: Long),ProgressScreen(gid, token, page), etc.中:
DownloadManager.kt、ci.yml及其他文件均无改动。修复完全集中在两个文件中,遵循标准的 compose-destinations route args 模式,与GalleryCommentsScreen(gid: Long)、ProgressScreen(gid, token, page)等一致。Testing / 测试方案
EN: Start downloading 2+ galleries sequentially. While one is active, pull down the notification shade and tap the download notification. Verify the Downloads screen scrolls to the currently downloading gallery.
中: 开始顺序下载 2 个以上画廊。在正在下载时下拉通知栏并点击下载通知。确认下载页面滚动到当前正在下载的画廊。
EN: Switch to grid view and repeat test 1.
中: 切换到网格视图后重复测试 1。
EN: Tap notification again while already on the Downloads screen. Verify it scrolls again.
中: 已在下载页面时再次点击通知。确认再次滚动。
EN: After tapping notification, press back. Verify you return directly to the home page (not through an old Downloads screen instance).
中: 点击通知后按返回键。确认直接返回首页(不会经过旧的下载页面)。