Skip to content

Commit

Permalink
Add default sort label (comment vs post) to action sheet (#1471)
Browse files Browse the repository at this point in the history
Resolves #1456
  • Loading branch information
aeharding authored May 11, 2024
1 parent beed451 commit ca4e79c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/features/feed/PostSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@ export default function PostSort({ sort, setSort }: PostSortProps) {
);
}

export function useSelectPostSort(onSelected: (sort: SortType) => void) {
interface Options {
title?: string;
}

export function useSelectPostSort(
onSelected: (sort: SortType) => void,
options?: Options,
) {
const [presentInitialSortActionSheet] = useIonActionSheet();
const [presentTopSortActionSheet] = useIonActionSheet();

function present(sort: SortType) {
presentInitialSortActionSheet({
header: "Sort by...",
header: options?.title ?? "Sort by...",
cssClass: "left-align-buttons",
buttons: BUTTONS.map((b) => ({
...b,
Expand Down
1 change: 1 addition & 0 deletions src/features/settings/general/comments/DefaultSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function DefaultSort() {
return (
<SettingSelector
title="Default Sort"
openTitle="Default Comment Sort"
selected={defaultCommentSort}
setSelected={setDefaultCommentSort}
options={OCommentDefaultSort}
Expand Down
9 changes: 6 additions & 3 deletions src/features/settings/general/posts/DefaultSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ export default function DefaultSort() {
(state) => state.settings.general.posts.sort,
);

const present = useSelectPostSort((newSort) => {
dispatch(setDefaultPostSort(newSort));
});
const present = useSelectPostSort(
(newSort) => {
dispatch(setDefaultPostSort(newSort));
},
{ title: "Default Post Sort" },
);

return (
<IonItem button onClick={() => present(defaultPostSort)} detail={false}>
Expand Down

0 comments on commit ca4e79c

Please sign in to comment.