-
Notifications
You must be signed in to change notification settings - Fork 148
feat: add 'Latest Only' dropdown to release timeline #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -346,6 +346,7 @@ interface AppActions { | |||||||||||||
| // Release Timeline View actions | ||||||||||||||
| setReleaseViewMode: (mode: 'timeline' | 'repository') => void; | ||||||||||||||
| setReleaseShowMode: (mode: 'all' | 'unread') => void; | ||||||||||||||
| setReleaseLatestMode: (mode: 'all' | 'latest') => void; | ||||||||||||||
| setReleaseSelectedFilters: (filters: string[]) => void; | ||||||||||||||
| toggleReleaseSelectedFilter: (filterId: string) => void; | ||||||||||||||
| clearReleaseSelectedFilters: () => void; | ||||||||||||||
|
|
@@ -439,6 +440,7 @@ type PersistedAppState = Partial< | |||||||||||||
| | 'forkExpandedRepositories' | ||||||||||||||
| | 'releaseViewMode' | ||||||||||||||
| | 'releaseShowMode' | ||||||||||||||
| | 'releaseLatestMode' | ||||||||||||||
| | 'releaseSelectedFilters' | ||||||||||||||
| | 'releaseSearchQuery' | ||||||||||||||
| | 'includePreRelease' | ||||||||||||||
|
|
@@ -562,6 +564,7 @@ const normalizePersistedState = ( | |||||||||||||
| isAuthenticated: !!(safePersisted.user && safePersisted.githubToken), | ||||||||||||||
| releaseViewMode: safePersisted.releaseViewMode || 'timeline', | ||||||||||||||
| releaseShowMode: safePersisted.releaseShowMode === 'unread' ? 'unread' : 'all', | ||||||||||||||
| releaseLatestMode: safePersisted.releaseLatestMode === 'latest' ? 'latest' : 'all', | ||||||||||||||
| releaseSelectedFilters: Array.isArray(safePersisted.releaseSelectedFilters) ? safePersisted.releaseSelectedFilters : [], | ||||||||||||||
| releaseSearchQuery: typeof safePersisted.releaseSearchQuery === 'string' ? safePersisted.releaseSearchQuery : '', | ||||||||||||||
| discoveryChannels: (() => { | ||||||||||||||
|
|
@@ -1270,6 +1273,22 @@ export const useAppStore = create<AppState & AppActions>()( | |||||||||||||
| markReleaseAsRead: (releaseId) => set((state) => { | ||||||||||||||
| const newReadReleases = new Set(state.readReleases); | ||||||||||||||
| newReadReleases.add(releaseId); | ||||||||||||||
|
|
||||||||||||||
| // In 'latest' mode, marking the latest release as read also marks all other releases of that repo | ||||||||||||||
| if (state.releaseLatestMode === 'latest') { | ||||||||||||||
| const markedRelease = state.releases.find(r => r.id === releaseId); | ||||||||||||||
| if (markedRelease) { | ||||||||||||||
| const repoId = markedRelease.repository.id; | ||||||||||||||
| const repoReleases = state.releases.filter(r => r.repository.id === repoId); | ||||||||||||||
| const latestRepoRelease = repoReleases.reduce((latest, r) => | ||||||||||||||
| new Date(r.published_at) > new Date(latest.published_at) ? r : latest | ||||||||||||||
| , repoReleases[0]); | ||||||||||||||
|
Comment on lines
+1284
to
+1286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
Suggested change
|
||||||||||||||
| if (latestRepoRelease && latestRepoRelease.id === releaseId) { | ||||||||||||||
| repoReleases.forEach(r => newReadReleases.add(r.id)); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return { readReleases: newReadReleases }; | ||||||||||||||
| }), | ||||||||||||||
| markAllReleasesAsRead: () => set((state) => { | ||||||||||||||
|
|
@@ -1569,6 +1588,7 @@ export const useAppStore = create<AppState & AppActions>()( | |||||||||||||
| // Release Timeline View actions | ||||||||||||||
| setReleaseViewMode: (releaseViewMode) => set({ releaseViewMode }), | ||||||||||||||
| setReleaseShowMode: (releaseShowMode) => set({ releaseShowMode }), | ||||||||||||||
| setReleaseLatestMode: (releaseLatestMode) => set({ releaseLatestMode }), | ||||||||||||||
| setReleaseSelectedFilters: (releaseSelectedFilters) => set({ releaseSelectedFilters }), | ||||||||||||||
| toggleReleaseSelectedFilter: (filterId) => set((state) => ({ | ||||||||||||||
| releaseSelectedFilters: state.releaseSelectedFilters.includes(filterId) | ||||||||||||||
|
|
||||||||||||||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
preUnreadFilteredReleasesis already sorted in descending order bypublished_at(newest first), the first release encountered for each repository is guaranteed to be the latest one. We can simplify this logic by checking if the repository ID is already in the map, completely avoiding the overhead of parsing and comparingDateobjects.