mobile: archive notes

This commit is contained in:
Ammar Ahmed
2025-05-12 12:17:11 +05:00
committed by Abdullah Atta
parent b63be2de15
commit fa8aa4d88f
12 changed files with 2401 additions and 2224 deletions

View File

@@ -36,6 +36,7 @@ import Paragraph from "../ui/typography/paragraph";
const TOP_BAR_ITEMS: ActionId[] = [ const TOP_BAR_ITEMS: ActionId[] = [
"pin", "pin",
"favorite", "favorite",
"archive",
"lock-unlock", "lock-unlock",
"publish", "publish",
"local-only", "local-only",

View File

@@ -66,9 +66,11 @@ import { convertNoteToText } from "../utils/note-to-text";
import { sleep } from "../utils/time"; import { sleep } from "../utils/time";
import SettingsService from "../services/settings"; import SettingsService from "../services/settings";
import { useSettingStore } from "../stores/use-setting-store"; import { useSettingStore } from "../stores/use-setting-store";
import { useArchivedStore } from "../stores/use-archived-store";
export type ActionId = export type ActionId =
| "select" | "select"
| "archive"
| "restore" | "restore"
| "delete" | "delete"
| "reorder" | "reorder"
@@ -972,6 +974,19 @@ export const useActions = ({
reference: item as ItemReference reference: item as ItemReference
}); });
} }
},
{
id: "archive",
title: !item.archived ? strings.archive() : strings.unarchive(),
icon: "archive",
onPress: async () => {
db.notes.archive(!item.archived, item.id);
setItem((await db.notes.note(item.id)) as Item);
Navigation.queueRoutesForUpdate();
useArchivedStore.getState().refresh();
},
checked: item.archived,
isToggle: true
} }
); );

View File

@@ -43,7 +43,7 @@ let Reminders: any = null;
let Monographs: any = null; let Monographs: any = null;
let TaggedNotes: any = null; let TaggedNotes: any = null;
let ColoredNotes: any = null; let ColoredNotes: any = null;
let Archive: any = null;
const AppNavigation = React.memo( const AppNavigation = React.memo(
() => { () => {
const { colors } = useThemeColors(); const { colors } = useThemeColors();
@@ -192,6 +192,14 @@ const AppNavigation = React.memo(
initialParams={home.name === "ColoredNotes" ? home.params : undefined} initialParams={home.name === "ColoredNotes" ? home.params : undefined}
/> />
<AppStack.Screen
name="Archive"
getComponent={() => {
Archive = Archive || require("../screens/archive").default;
return Archive;
}}
/>
<AppStack.Screen <AppStack.Screen
name="Reminders" name="Reminders"
getComponent={() => { getComponent={() => {

View File

@@ -0,0 +1,88 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import DelayLayout from "../../components/delay-layout";
import { Header } from "../../components/header";
import List from "../../components/list";
import SelectionHeader from "../../components/selection-header";
import { useNavigationFocus } from "../../hooks/use-navigation-focus";
import Navigation, { NavigationProps } from "../../services/navigation";
import SettingsService from "../../services/settings";
import useNavigationStore from "../../stores/use-navigation-store";
import { db } from "../../common/database";
import { strings } from "@notesnook/intl";
import { useArchived } from "../../stores/use-archived-store";
export const Archive = ({ navigation, route }: NavigationProps<"Archive">) => {
const [archive, loading, refresh] = useArchived();
const isFocused = useNavigationFocus(navigation, {
onFocus: (prev) => {
Navigation.routeNeedsUpdate(
route.name,
Navigation.routeUpdateFunctions[route.name]
);
useNavigationStore.getState().setFocusedRouteId(route?.name);
return false;
},
onBlur: () => false,
delay: SettingsService.get().homepage === route.name ? 1 : -1
});
return (
<>
<SelectionHeader id={route.name} items={archive} type="note" />
<Header
renderedInRoute={route.name}
title={strings.routes[route.name]()}
canGoBack={false}
hasSearch={true}
id={route.name}
onSearch={() => {
Navigation.push("Search", {
placeholder: strings.searchInRoute(route.name),
type: "note",
title: route.name,
route: route.name,
items: db.notes.archived
});
}}
/>
<DelayLayout wait={loading}>
<List
data={archive}
dataType="note"
onRefresh={() => {
refresh();
}}
renderedInRoute="Archive"
loading={loading}
placeholder={{
title: strings.yourArchive(),
paragraph: strings.yourArchiveIsEmpty(),
loading: strings.loadingArchive()
}}
headerTitle={strings.routes.Archive()}
/>
</DelayLayout>
</>
);
};
export default Archive;

View File

@@ -37,6 +37,7 @@ import {
rootNavigatorRef rootNavigatorRef
} from "../utils/global-refs"; } from "../utils/global-refs";
import { eSendEvent } from "./event-manager"; import { eSendEvent } from "./event-manager";
import { useArchivedStore } from "../stores/use-archived-store";
/** /**
* Routes that should be updated on focus * Routes that should be updated on focus
@@ -66,7 +67,8 @@ const routeNames = {
Reminders: "Reminders", Reminders: "Reminders",
MoveNotebook: "MoveNotebook", MoveNotebook: "MoveNotebook",
LinkNotebooks: "LinkNotebooks", LinkNotebooks: "LinkNotebooks",
MoveNotes: "MoveNotes" MoveNotes: "MoveNotes",
Archive: "Archive"
}; };
export type NavigationProps<T extends RouteName> = NativeStackScreenProps< export type NavigationProps<T extends RouteName> = NativeStackScreenProps<
@@ -92,7 +94,8 @@ const routeUpdateFunctions: {
TopicNotes: (params) => eSendEvent("TopicNotes", params), TopicNotes: (params) => eSendEvent("TopicNotes", params),
Monographs: (params) => eSendEvent("Monographs", params), Monographs: (params) => eSendEvent("Monographs", params),
Reminders: () => useReminderStore.getState().refresh(), Reminders: () => useReminderStore.getState().refresh(),
Search: () => eSendEvent(eOnRefreshSearch) Search: () => eSendEvent(eOnRefreshSearch),
Archive: () => useArchivedStore.getState().refresh()
}; };
function clearRouteFromQueue(routeName: RouteName) { function clearRouteFromQueue(routeName: RouteName) {

View File

@@ -0,0 +1,30 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { db } from "../common/database";
import createDBCollectionStore from "./create-db-collection-store";
const { useStore: useArchivedStore, useCollection: useArchived } =
createDBCollectionStore({
getCollection: () =>
db.notes.archived.grouped(db.settings.getGroupOptions("archive")),
eagerlyFetchFirstBatch: true
});
export { useArchivedStore, useArchived };

View File

@@ -74,6 +74,7 @@ export interface RouteParams extends ParamListBase {
TaggedNotes: NotesScreenParams; TaggedNotes: NotesScreenParams;
ColoredNotes: NotesScreenParams; ColoredNotes: NotesScreenParams;
TopicNotes: NotesScreenParams; TopicNotes: NotesScreenParams;
Archive: GenericRouteParam;
Monographs: NotesScreenParams; Monographs: NotesScreenParams;
Reminders: GenericRouteParam; Reminders: GenericRouteParam;
SettingsGroup: GenericRouteParam; SettingsGroup: GenericRouteParam;

View File

@@ -77,12 +77,13 @@ export const MenuItemsList: SideMenuItem[] = [
}, },
type: "side-menu-item" type: "side-menu-item"
}, },
// { {
// dataType: "note", dataType: "note",
// id: "Archive", id: "Archive",
// title: "Archive", title: "Archive",
// icon: "archive" icon: "archive",
// }, type: "side-menu-item"
},
{ {
dataType: "note", dataType: "note",
id: "Trash", id: "Trash",

View File

@@ -1899,7 +1899,7 @@ SPEC CHECKSUMS:
react-native-orientation-locker: cc6f357b289a2e0dd2210fea0c52cb8e0727fdaa react-native-orientation-locker: cc6f357b289a2e0dd2210fea0c52cb8e0727fdaa
react-native-pager-view: f530c9533319e0355da3551ade81d471b5a04c44 react-native-pager-view: f530c9533319e0355da3551ade81d471b5a04c44
react-native-pdf: da10473ae54555c373c62af671da8fe0eef846e2 react-native-pdf: da10473ae54555c373c62af671da8fe0eef846e2
react-native-quick-sqlite: 80b5b3405bfc92e97b6041d2c2a446800bea6ad7 react-native-quick-sqlite: ae74515f7a941f3e7f9e5ea7aff603da1b1c3010
react-native-safe-area-context: b72c4611af2e86d80a59ac76279043d8f75f454c react-native-safe-area-context: b72c4611af2e86d80a59ac76279043d8f75f454c
react-native-screenguard: 82437eeb0086a90b5e5d7e54130bb04fb406373e react-native-screenguard: 82437eeb0086a90b5e5d7e54130bb04fb406373e
react-native-share-extension: bcb7e466390a9e50c742f4b1019d6f181aedd7ad react-native-share-extension: bcb7e466390a9e50c742f4b1019d6f181aedd7ad

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -948,6 +948,7 @@ $headline$: Use starting line of the note as title.`,
yourNotebooks: () => t`Your notebooks`, yourNotebooks: () => t`Your notebooks`,
yourReminders: () => t`Your reminders`, yourReminders: () => t`Your reminders`,
yourMonographs: () => t`Your monographs`, yourMonographs: () => t`Your monographs`,
yourArchive: () => t`Your archive`,
favoritesEmpty: () => t`You have not favorited any notes yet`, favoritesEmpty: () => t`You have not favorited any notes yet`,
notesEmpty: () => t`You have not created any notes yet`, notesEmpty: () => t`You have not created any notes yet`,
tagsEmpty: () => t`You have not added any tags yet`, tagsEmpty: () => t`You have not added any tags yet`,
@@ -960,6 +961,7 @@ $headline$: Use starting line of the note as title.`,
loadingNotebooks: () => t`Loading your notebooks`, loadingNotebooks: () => t`Loading your notebooks`,
loadingReminders: () => t`Loading your reminders`, loadingReminders: () => t`Loading your reminders`,
loadingMonographs: () => t`Loading your monographs`, loadingMonographs: () => t`Loading your monographs`,
loadingArchive: () => t`Loading your archive`,
addFirstNote: () => t`Add your first note`, addFirstNote: () => t`Add your first note`,
addFirstNotebook: () => t`Add your first notebook`, addFirstNotebook: () => t`Add your first notebook`,
setReminder: () => t`Set a reminder`, setReminder: () => t`Set a reminder`,
@@ -1512,7 +1514,8 @@ For example:
Editor: () => t`Editor`, Editor: () => t`Editor`,
Home: () => t`Home`, Home: () => t`Home`,
Search: () => t`Search`, Search: () => t`Search`,
Monographs: () => t`Monographs` Monographs: () => t`Monographs`,
Archive: () => t`Archive`
}, },
searchInRoute: ( searchInRoute: (
routeName: keyof typeof SEARCH_IN_ROUTE_STRINGS | ({} & string) routeName: keyof typeof SEARCH_IN_ROUTE_STRINGS | ({} & string)
@@ -2468,5 +2471,6 @@ Use this if changes from other devices are not appearing on this device. This wi
defaultSidebarTabDesc: () => t`Select the default sidebar tab`, defaultSidebarTabDesc: () => t`Select the default sidebar tab`,
unsetAsHomepage: () => t`Reset homepage`, unsetAsHomepage: () => t`Reset homepage`,
archive: () => t`Archive`, archive: () => t`Archive`,
yourArchiveIsEmpty: () => t`Your archive is empty` yourArchiveIsEmpty: () => t`Your archive is empty`,
unarchive: () => t`Unarchive`
}; };