Repository navigation
Conversation
Persists the most recently selected room per account as a JSON clientId->roomId map in preferences (following the existing storeRoomsListCache pattern), records it in MainPage.selectRoom, and re-opens it in initState when launched without a deep-link target. Follow-up to commetchat#778 (spaces restore). Deep-link open-into-room remains tracked under commetchat#1070 (MSC4550) and is out of scope here.
Contributor
|
closing as this seems AI generated. Please stick to the contribution guide |
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.
Summary
Open the app back on the last room you were reading.
Commet currently always lands on the room list when cold-started. Most users who
open a chat app do it to continue a conversation they were in a moment ago —
especially on mobile where a phone-call, a doze, or a background-kill has closed
the app. This PR persists the last room you opened in each account and reopens
it on the next launch, mirroring the existing deep-link restore path.
This follows up on #778, which was scoped to spaces. The behavior here
covers the general (non-space) room-list case.
How it works
main_page.dartalready handles "restore a room on launch" when the app isopened via a deep link (see the block starting at
if (client == null && widget.initialRoom != null)). This PR reuses the samepattern for the no-deep-link case and adds the persistence it needs:
preferences.dart_rememberedRoomspreference — aMap<clientIdentifier, roomIdentifier>stored as JSON via
SharedPreferences, matching the existingstoreRoomsListCachepattern.getRememberedRoom(clientId)/setRememberedRoom(clientId, roomId).An empty
roomIdremoves the entry (logout-friendly hook, even though wedon't wire the logout cleanup in this PR — the restore path already guards
against a stale id, so a left-behind entry simply won't restore anything).
main_page.dartselectRoom(...): recordroom.client.identifier → room.identifiersothe most recently opened room wins on next launch.
initState: if the userdidn't come in via a deep link, and no room is currently selected, fetch
the remembered room id for this client and
selectRoom(...)it. We guardon
client.isLoggedIn()and oncurrentRoom == nullto keep the deep-linkpath and any manual navigation from being clobbered.
Multi-account: keys are per
client.identifier, so logged-in accounts each gettheir own remembered room. The app's existing single-"active" account model
means only one is visible on the front screen at a time, so no disambiguation
UI is needed.
What's not in this PR
small, isolated change. Trivial follow-up if maintainers want it.
commetchat://room/<id>): also not included — thatrequires the URL-scheme + alias-resolution work that [Feature] Implement MSC4550 explicit links #1070 (MSC4550) is
targeting, and I didn't want to bundle that in here.
Testing
Not compiled/
flutter analyzed (no Flutter toolchain on the box that producedthis). The code is small, mirrors existing patterns in
preferences.dartandthe
initialRoomrestore block inmain_page.dart, and should pass CI as-is.Manual test plan once CI is green:
tcmatrix.duckdns.org→ open Room A → force-stop the app → relaunch →expect to land in Room A.
in Room B (most-recently-opened wins).
expect to land in the deep-link room, not the remembered one.
log out of A → relaunch → should land in B's last room (A is gone).
Files changed
commet/lib/config/preferences.dart(+30)commet/lib/ui/pages/main/main_page.dart(+16)Caveats / known limitations
Space X, closed the app, and last touched an in-app Space Y screen, you'll
still come back to A. That's the right default — but flagging it so we can
follow up on [Feature] Return to last visited room when switching spaces #778 separately.
unread filter view, we ignore that). Trivial follow-up if wanted.
/cc @commetchat maintain — happy to adjust to fit house style / split into
smaller commits / add a unit test for
getRememberedRoom/setRememberedRoomwhichever is preferred.