2022-08-30 16:13:11 +05:00
|
|
|
/* This file is part of the Notesnook project (https://notesnook.com/)
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2022 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-01-03 10:16:54 +05:00
|
|
|
import Vault from "../common/vault";
|
2021-06-05 23:54:20 +05:00
|
|
|
import {
|
|
|
|
|
showBuyDialog,
|
2021-07-20 12:47:11 +05:00
|
|
|
showCreateTagDialog,
|
|
|
|
|
showEditTagDialog,
|
2021-06-05 23:54:20 +05:00
|
|
|
showEmailVerificationDialog,
|
2021-11-09 14:50:28 +05:00
|
|
|
showFeatureDialog,
|
2022-08-26 16:19:39 +05:00
|
|
|
showOnboardingDialog
|
2021-06-05 23:54:20 +05:00
|
|
|
} from "../common/dialog-controller";
|
2021-01-02 22:24:07 +05:00
|
|
|
import {
|
|
|
|
|
showAddNotebookDialog,
|
2022-08-26 16:19:39 +05:00
|
|
|
showEditNotebookDialog
|
2021-02-16 22:28:19 +05:00
|
|
|
} from "../common/dialog-controller";
|
|
|
|
|
import { closeOpenedDialog } from "../common/dialog-controller";
|
2021-01-02 22:24:07 +05:00
|
|
|
import RouteContainer from "../components/route-container";
|
2021-05-27 12:29:58 +05:00
|
|
|
import DiffViewer from "../components/diff-viewer";
|
2021-01-02 22:24:07 +05:00
|
|
|
import Unlock from "../components/unlock";
|
2021-01-03 10:16:54 +05:00
|
|
|
import { store as appStore } from "../stores/app-store";
|
2021-01-02 22:24:07 +05:00
|
|
|
import { store as editorStore } from "../stores/editor-store";
|
2021-07-17 08:50:18 +05:00
|
|
|
import { isMobile } from "../utils/dimensions";
|
2021-01-07 17:47:46 +05:00
|
|
|
import {
|
|
|
|
|
showEditTopicDialog,
|
2022-08-26 16:19:39 +05:00
|
|
|
showCreateTopicDialog
|
2021-02-16 22:28:19 +05:00
|
|
|
} from "../common/dialog-controller";
|
2021-02-16 11:49:03 +05:00
|
|
|
import { hashNavigate } from ".";
|
2021-02-18 20:29:59 +05:00
|
|
|
import EditorPlaceholder from "../components/editor/-placeholder";
|
2022-07-26 23:19:05 +05:00
|
|
|
import Editor from "../components/editor";
|
2021-01-02 22:24:07 +05:00
|
|
|
|
|
|
|
|
const hashroutes = {
|
|
|
|
|
"/": () => {
|
2021-02-18 20:29:59 +05:00
|
|
|
return !editorStore.get().session.state && <EditorPlaceholder />;
|
2021-01-02 22:24:07 +05:00
|
|
|
},
|
2021-01-04 01:57:32 +05:00
|
|
|
"/email/verify": () => {
|
|
|
|
|
showEmailVerificationDialog();
|
|
|
|
|
},
|
2021-01-02 22:24:07 +05:00
|
|
|
"/notebooks/create": () => {
|
|
|
|
|
showAddNotebookDialog();
|
|
|
|
|
},
|
|
|
|
|
"/notebooks/:notebookId/edit": ({ notebookId }) => {
|
|
|
|
|
showEditNotebookDialog(notebookId);
|
|
|
|
|
},
|
2021-01-07 17:47:46 +05:00
|
|
|
"/topics/create": () => {
|
2021-07-20 23:02:07 +05:00
|
|
|
showCreateTopicDialog();
|
2021-01-07 17:47:46 +05:00
|
|
|
},
|
|
|
|
|
"/notebooks/:notebookId/topics/:topicId/edit": ({ notebookId, topicId }) => {
|
|
|
|
|
showEditTopicDialog(notebookId, topicId);
|
|
|
|
|
},
|
2021-07-20 12:47:11 +05:00
|
|
|
"/tags/create": () => {
|
|
|
|
|
showCreateTagDialog();
|
|
|
|
|
},
|
|
|
|
|
"/tags/:tagId/edit": ({ tagId }) => {
|
|
|
|
|
showEditTagDialog(tagId);
|
|
|
|
|
},
|
2021-01-04 12:59:45 +05:00
|
|
|
"/notes/create": () => {
|
2021-06-16 09:59:01 +05:00
|
|
|
closeOpenedDialog();
|
2021-02-27 10:44:13 +05:00
|
|
|
hashNavigate("/notes/create", { addNonce: true, replace: true });
|
|
|
|
|
},
|
|
|
|
|
"/notes/create/:nonce": ({ nonce }) => {
|
2021-06-16 09:59:01 +05:00
|
|
|
closeOpenedDialog();
|
2022-07-26 23:19:05 +05:00
|
|
|
return <Editor noteId={0} nonce={nonce} />;
|
2021-01-04 12:59:45 +05:00
|
|
|
},
|
2021-01-02 22:24:07 +05:00
|
|
|
"/notes/:noteId/edit": ({ noteId }) => {
|
2021-06-16 09:59:01 +05:00
|
|
|
closeOpenedDialog();
|
2022-04-01 20:07:57 +05:00
|
|
|
|
2022-07-26 23:19:05 +05:00
|
|
|
return <Editor noteId={noteId} />;
|
2021-01-02 22:24:07 +05:00
|
|
|
},
|
|
|
|
|
"/notes/:noteId/unlock": ({ noteId }) => {
|
2021-06-16 09:59:01 +05:00
|
|
|
closeOpenedDialog();
|
2021-01-02 22:24:07 +05:00
|
|
|
return (
|
|
|
|
|
<RouteContainer
|
2021-02-16 11:49:03 +05:00
|
|
|
buttons={{
|
|
|
|
|
back: isMobile()
|
|
|
|
|
? {
|
|
|
|
|
title: "Go back",
|
2021-02-27 10:44:13 +05:00
|
|
|
action: () =>
|
|
|
|
|
hashNavigate("/notes/create", {
|
|
|
|
|
addNonce: true,
|
2022-08-26 16:19:39 +05:00
|
|
|
replace: true
|
|
|
|
|
})
|
2021-02-16 11:49:03 +05:00
|
|
|
}
|
2022-08-26 16:19:39 +05:00
|
|
|
: undefined
|
2021-02-16 11:49:03 +05:00
|
|
|
}}
|
|
|
|
|
component={<Unlock noteId={noteId} />}
|
2021-01-02 22:24:07 +05:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
"/notes/:noteId/conflict": ({ noteId }) => {
|
2021-06-16 09:59:01 +05:00
|
|
|
closeOpenedDialog();
|
2021-05-27 12:29:58 +05:00
|
|
|
return <DiffViewer noteId={noteId} />;
|
2021-01-02 22:24:07 +05:00
|
|
|
},
|
2021-01-03 10:16:54 +05:00
|
|
|
"/vault/changePassword": () => {
|
|
|
|
|
Vault.changeVaultPassword();
|
|
|
|
|
},
|
|
|
|
|
"/vault/create": () => {
|
|
|
|
|
Vault.createVault().then((res) => {
|
|
|
|
|
appStore.setIsVaultCreated(res);
|
|
|
|
|
});
|
|
|
|
|
},
|
2021-06-05 23:54:20 +05:00
|
|
|
"/buy": () => {
|
|
|
|
|
showBuyDialog();
|
|
|
|
|
},
|
2021-04-07 09:28:22 +05:00
|
|
|
"/buy/:code": ({ code }) => {
|
2021-06-28 20:44:58 +05:00
|
|
|
showBuyDialog("monthly", code);
|
|
|
|
|
},
|
|
|
|
|
"/buy/:plan/:code": ({ plan, code }) => {
|
|
|
|
|
showBuyDialog(plan, code);
|
2021-04-07 09:28:22 +05:00
|
|
|
},
|
2021-11-09 14:50:28 +05:00
|
|
|
"/welcome": () => {
|
2022-02-17 21:27:16 +05:00
|
|
|
showOnboardingDialog("new");
|
2021-11-09 14:50:28 +05:00
|
|
|
},
|
|
|
|
|
"/confirmed": () => {
|
|
|
|
|
showFeatureDialog("confirmed");
|
2022-08-26 16:19:39 +05:00
|
|
|
}
|
2021-01-02 22:24:07 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default hashroutes;
|