Skip to content

Commit

Permalink
feat: sortable feed list
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Aug 23, 2024
1 parent b9fecc4 commit fdd2623
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions icons/mgc/AZ_sort_ascending_letters_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/AZ_sort_descending_letters_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/list_collapse_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/list_expansion_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/sort_ascending_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/sort_descending_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/renderer/src/modules/feed-column/atom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { createAtomHooks } from "@renderer/lib/jotai"
import { getStorageNS } from "@renderer/lib/ns"
import { atomWithStorage } from "jotai/utils"

export type FeedListSortBy = "count" | "alphabetical"
export type FeedListSortOrder = "asc" | "desc"
const [
,
,
useFeedListSort,
,
getFeedListSort,
setFeedListSort,
useFeedListSortSelector,
] = createAtomHooks(
atomWithStorage(
getStorageNS("feedListSort"),
{
by: "count" as FeedListSortBy,
order: "desc" as FeedListSortOrder,
},
undefined,
{ getOnInit: true },
),
)

export { getFeedListSort, useFeedListSort, useFeedListSortSelector }

export const setFeedListSortBy = (by: FeedListSortBy) => {
setFeedListSort({
...getFeedListSort(),
by,
})
}

export const setFeedListSortOrder = (order: FeedListSortOrder) => {
setFeedListSort({
...getFeedListSort(),
order,
})
}

0 comments on commit fdd2623

Please sign in to comment.