Persist selected board and auto-select most recent image across browser sessions#92
Conversation
lstein
left a comment
There was a problem hiding this comment.
The previously-selected image board is correctly restored. Thank you.
At load time, would it be possible to select the most recent image in the current image board so that it displays in the viewer? This would greatly improve the UX.
Yes — this is already handled by the existing
No additional code changes are needed — the |
|
@copilot In practice the automatic selection of the most recent image is not working. The correct gallery is being selected, but the Viewer window always says "No Image Selected." Could you recheck the code and your reasoning? |
Found and fixed the root cause (commit The The fix makes the effect |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
… works on startup Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
b0216e5 to
f2e25a8
Compare
Summary
The gallery's selected board (
selectedBoardId) was excluded from redux-remember persistence, causing it to reset to "none" (uncategorized) on every page load. Removing it frompersistDenylistrestores the board on reload.Additionally, at load time the most recent image in the restored board is automatically selected and displayed in the viewer. This is done by the
appStartedlistener, whichawaits the firstgetImageNamesresponse and selectspayload.image_names[0](the most recent image, orderedDESCby default) whenever no image is currently selected. Sinceselectionis still inpersistDenylist(always resets to[]on load), this reliably fires on every startup.Bug fix in
appStartedlistener: The original effect was synchronous — it calledtake(...).then(...)and returned immediately. RTK listener middleware aborts the listener'sinternalTaskControlleras soon as a synchronous effect returns, causingraceWithSignalinsidetaketo reject before any network response arrives, so the.then()callback never fired. The fix makes the effectasyncand usesawait take(imagesApi.endpoints.getImageNames.matchFulfilled, 5000), keeping the controller alive until the query resolves or times out.Graceful fallback is already handled: the existing
addArchivedOrDeletedBoardListenervalidates the restoredselectedBoardIdagainst thelistAllBoardsresponse on app init and resets to'none'if the board has been deleted, archived, or is otherwise unavailable.Related Issues / Discussions
QA Instructions
Merge Plan
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.