-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also add general settings page and refactor appearanceSlice to settingsSlice Co-authored-by: Alexander Harding <2166114+aeharding@users.noreply.github.com>
- Loading branch information
1 parent
db5046a
commit 89ad285
Showing
28 changed files
with
275 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Comments from "./comments/Comments"; | ||
|
||
export default function GeneralSettings() { | ||
return ( | ||
<> | ||
<Comments /> | ||
</> | ||
); | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { ActionSheetButton, IonActionSheet, IonLabel } from "@ionic/react"; | ||
import { startCase } from "lodash"; | ||
import { InsetIonItem } from "../../../user/Profile"; | ||
import { useAppDispatch, useAppSelector } from "../../../../store"; | ||
import { useState } from "react"; | ||
import { | ||
CommentDefaultSort, | ||
OCommentDefaultSort, | ||
} from "../../../../services/db"; | ||
import { IonActionSheetCustomEvent, OverlayEventDetail } from "@ionic/core"; | ||
import { setDefaultCommentSort } from "../../settingsSlice"; | ||
import { getSortIcon } from "../../../comment/CommentSort"; | ||
|
||
const BUTTONS: ActionSheetButton<CommentDefaultSort>[] = Object.values( | ||
OCommentDefaultSort | ||
).map(function (commentSort) { | ||
return { | ||
text: startCase(commentSort), | ||
data: commentSort, | ||
icon: getSortIcon(commentSort), | ||
} as ActionSheetButton<CommentDefaultSort>; | ||
}); | ||
|
||
export default function DefaultSort() { | ||
const [open, setOpen] = useState(false); | ||
|
||
const dispatch = useAppDispatch(); | ||
const postsAppearanceType = useAppSelector( | ||
(state) => state.settings.general.comments.sort | ||
); | ||
|
||
return ( | ||
<> | ||
<InsetIonItem button onClick={() => setOpen(true)}> | ||
<IonLabel>Default Sort</IonLabel> | ||
<IonLabel slot="end" color="medium"> | ||
{startCase(postsAppearanceType)} | ||
</IonLabel> | ||
<IonActionSheet | ||
cssClass="left-align-buttons" | ||
isOpen={open} | ||
onDidDismiss={() => setOpen(false)} | ||
onWillDismiss={( | ||
e: IonActionSheetCustomEvent<OverlayEventDetail<CommentDefaultSort>> | ||
) => { | ||
if (e.detail.data) { | ||
dispatch(setDefaultCommentSort(e.detail.data)); | ||
} | ||
}} | ||
header="Default Comments Sort..." | ||
buttons={BUTTONS.map((b) => ({ | ||
...b, | ||
role: postsAppearanceType === b.data ? "selected" : undefined, | ||
}))} | ||
/> | ||
</InsetIonItem> | ||
</> | ||
); | ||
} |
Oops, something went wrong.