Skip to content

Commit

Permalink
mobile: sort reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed authored and thecodrr committed Mar 4, 2024
1 parent 696116a commit 6e135cd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,14 @@ export const SectionHeader = React.memo(
alignItems: "center"
}}
>
{index === 0 && (
{index === 0 ? (
<>
<Button
onPress={() => {
presentSheet({
component: <Sort screen={screen} type={type} />
});
}}
hidden={screen === "Reminders"}
tooltipText="Change sorting of items in list"
fwdRef={sortRef}
title={groupBy}
Expand Down Expand Up @@ -160,7 +159,7 @@ export const SectionHeader = React.memo(
size={SIZE.lg - 2}
/>
</>
)}
) : null}
</View>
</View>
);
Expand Down
5 changes: 5 additions & 0 deletions apps/mobile/app/components/sheets/sort/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ const Sort = ({ type, screen }) => {
? groupOptions.groupBy === "abc" ||
groupOptions.sortBy === "title"
? "A - Z"
: groupOptions.sortBy === "dueDate"
? "Earliest first"
: "Old - New"
: groupOptions.groupBy === "abc" ||
groupOptions.sortBy === "title"
? "Z - A"
: groupOptions.sortBy === "dueDate"
? "Latest first"
: "New - Old"
}
icon={
Expand Down Expand Up @@ -142,6 +146,7 @@ const Sort = ({ type, screen }) => {
/>
) : (
Object.keys(SORT).map((item) =>
(item === "dueDate" && screen !== "Reminders") ||
(item === "title" && groupOptions.groupBy !== "none") ||
((screen !== "Tags" || screen !== "Reminders") &&
item === "dateModified") ||
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/stores/use-reminder-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const useReminderStore = create<ReminderStore>((set) => ({
reminders: [],
setReminders: () => {
set({
reminders: groupReminders((db.reminders?.all as Reminder[]) || [])
reminders: groupReminders(
(db.reminders?.all as Reminder[]) || [],
db.settings?.getGroupOptions("reminders")
)
});
},
cleareReminders: () => set({ reminders: [] })
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/app/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const SORT = {
dateModified: "Date modified",
dateEdited: "Date edited",
dateCreated: "Date created",
title: "Title"
title: "Title",
dueDate: "Due date"
};

export const itemSkus = [
Expand Down

0 comments on commit 6e135cd

Please sign in to comment.