Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix walkthrough show after deleting notebooks

ammarahm-edcd49a32148a1
diff --git a/apps/mobile/src/components/launcher/index.js b/apps/mobile/src/components/launcher/index.js
index 038d817c8..b68725210 100644
--- a/apps/mobile/src/components/launcher/index.js
+++ b/apps/mobile/src/components/launcher/index.js
@@ -35,6 +35,7 @@ import Seperator from '../ui/seperator';
import { SvgView } from '../ui/svg';
import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
+import { Walkthrough } from '../walkthroughs';
const Launcher = () => {
const colors = useThemeStore(state => state.colors);
@@ -63,6 +64,7 @@ const Launcher = () => {
setNotes();
setFavorites();
setLoading(false);
+ Walkthrough.init();
};
const init = async () => {
diff --git a/apps/mobile/src/components/walkthroughs/index.tsx b/apps/mobile/src/components/walkthroughs/index.tsx
index c99f93837..cc460290c 100644
--- a/apps/mobile/src/components/walkthroughs/index.tsx
+++ b/apps/mobile/src/components/walkthroughs/index.tsx
@@ -107,6 +107,22 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
</View>
);
};
+let walkthroughState: { [name: string]: boolean } = {};
+
+Walkthrough.update = async (id: 'notebooks' | 'trialstarted' | 'emailconfirmed' | 'prouser') => {
+ console.log('walkthrough state', walkthroughState);
+ if (walkthroughState[id]) return;
+ walkthroughState[id] = true;
+ MMKV.setItem('walkthroughState', JSON.stringify(walkthroughState));
+};
+
+Walkthrough.init = async () => {
+ let json = await MMKV.getItem('walkthroughState');
+ if (walkthroughState) {
+ walkthroughState = JSON.parse(json);
+ console.log(walkthroughState);
+ }
+};
Walkthrough.present = async (
id: 'notebooks' | 'trialstarted' | 'emailconfirmed' | 'prouser',
@@ -114,18 +130,9 @@ Walkthrough.present = async (
nopersist?: boolean
) => {
if (!nopersist) {
- let walkthroughState = await MMKV.getItem('walkthroughState');
- if (walkthroughState) {
- walkthroughState = JSON.parse(walkthroughState);
- } else {
- //@ts-ignore
- walkthroughState = {};
- }
- //@ts-ignore
if (walkthroughState[id]) return;
//@ts-ignore
- walkthroughState[id] = true;
- MMKV.setItem('walkthroughState', JSON.stringify(walkthroughState));
+ Walkthrough.update(id);
}
//@ts-ignore
diff --git a/apps/mobile/src/screens/notebooks/index.js b/apps/mobile/src/screens/notebooks/index.js
index f45773e10..111a85e1e 100644
--- a/apps/mobile/src/screens/notebooks/index.js
+++ b/apps/mobile/src/screens/notebooks/index.js
@@ -55,6 +55,8 @@ export const Notebooks = ({ navigation }) => {
if (navigation.isFocused()) {
if (notebooks.length === 0) {
Walkthrough.present('notebooks');
+ } else {
+ Walkthrough.update('notebooks');
}
updateSearch();
}