android / android/nowinandroid

The way the interests feature stores the currently selected topic ID violates SSOT

Open
#2,006 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

On the `InterestsScreen` when a user taps on a topic, 2 things happen:

- a navigation event which pushes `TopicNavKey(topicId)` on to the back stack
- `InterestsViewModel` is updated with the selected topic Id

This violates SSOT because the currently selected topic Id is now stored in 2 places. We should come up with a better way of doing this. Ideas:

- Have `InterestsViewModel` derive the current selected topic id from the `TopicNavKey` on the back stack. This would require `InterestsViewModel` having access to `NavigationState`.
- Pass the `navigator` to `InterestsViewModel`. Then its `onTopicClick` method can navigate as well as updating its own currently selected topic ID (still violates SSOT but is architecturally better and simpler to implement).

Contributor guide

Open the contributing guide

Research direction

Start at the InterestsScreen topic-click handler and trace how TopicNavKey and the InterestsViewModel update state, then read the NavigationState path suggested in the issue. The work is done when the selected topic ID has one source of truth rather than being stored independently by navigation and the view model.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.