48 | What would you like to compare your inbox note's contents to when
49 | deciding whether or not to show a notification on startup?
50 |
51 |
52 | {
55 | $lastInbox.compareType = detail;
56 | }}
57 | />
58 |
59 |
60 | 'Compare to last tracked' will compare to a snapshot from when Obsidian
61 | was last closed. This is the default, and is most commonly used when you
62 | want to know if a note was changes externally outside of Obsidian.
63 |
64 |
65 | 'Compare to base' will compare to a base contents that you define. This
66 | is used for when you want to know if there's anything in your inbox
67 | note, even if there haven't been any changes to your note since your
68 | last startup.
69 |
70 | {:else if $store.walkthroughStatus === WalkthroughStatuses.setInboxPath}
71 |
72 | Let's setup which {$lastInbox.trackingType.toString()} will be your inbox
73 | {$lastInbox.trackingType.toString()}.
74 |
75 |
76 | {#if $lastInbox.trackingType === TrackingTypes.note}
77 |
78 | Select the note that you want to be notified of when it's contents
79 | are changed.
80 |
81 | file.path}
86 | on:change={async ({ detail }) => {
87 | if (detail !== $lastInbox.path) {
88 | await setInboxNote({
89 | app,
90 | notePath: detail,
91 | index: $lastInboxIndex,
92 | });
93 | }
94 | }}
95 | />
96 | {:else if $lastInbox.trackingType === TrackingTypes.folder}
97 |
98 | Select the folder that you want to be notifified of when files are
99 | added/removed to this folder outside of Obsidian.
100 |
101 | file.path}
106 | on:change={async ({ detail }) => {
107 | if (detail !== $lastInbox.path) {
108 | await setInboxFolder({
109 | app,
110 | folderPath: detail,
111 | index: $lastInboxIndex,
112 | });
113 | }
114 | }}
115 | />
116 | {/if}
117 | {:else if $store.walkthroughStatus === WalkthroughStatuses.restartObsidian}
118 | Alright, let's verify that this is working.
119 |
120 | {#if $lastInbox.trackingType === TrackingTypes.note && $lastInbox.compareType === "compareToBase"}
121 |
122 |
123 | Restart Obsidian. You should not get a notification, since
124 | you haven't added anything to your "Inbox" note aside from anything
125 | added before you ran the "Set inbox note" command.
126 |
127 | Add anything to your "Inbox" note.
128 |
129 | Restart Obsidian. You should get a notification, because your
130 | "Inbox" note no longer matches what you set it to when you ran the
131 | "Set inbox note" command.
132 |
133 |
134 | {:else if $lastInbox.trackingType === TrackingTypes.note && $lastInbox.compareType === "compareToLastTracked"}
135 |
136 |
137 | Restart Obsidian. You should not get a notification, since
138 | your Inbox note hasn't been updated externally.
139 |
140 |
141 | Close Obsidian, and add or remove some content to your Inbox
142 | note (located at "{$lastInbox.path}").
143 |
144 |
145 | Open Obsidian. You should get a notification, because your
146 | "Inbox" note was changed outside of Obsidian.
147 |
148 |
149 | {:else if $lastInbox.trackingType === TrackingTypes.folder}
150 |
151 |
152 | Restart Obsidian. You should not get a notification, since
153 | your Inbox folder hasn't been updated externally.
154 |
155 |
156 | Close Obsidian, and add or remove a note to your Inbox folder
157 | (located at "{$lastInbox.path}").
158 |
159 |
160 | Open Obsidian. You should get a notification, because your
161 | "Inbox" folder was changed outside of Obsidian.
162 |
163 |
164 | {/if}
165 |
166 | Click the "Next" button below to continue.
167 | {:else if $store.walkthroughStatus === WalkthroughStatuses.completed}
168 | You've completed the walkthrough!
169 |
170 |
171 | Feel free to close the walkthrough, or go back if you missed something!
172 | You can always re-open this walkthrough in the plugin settings.
173 |
174 | {/if}
175 |
176 |
177 | {#if $store.walkthroughStatus !== Object.values(WalkthroughStatuses)[1]}
178 | Back
179 | {/if}
180 | {#if $store.walkthroughStatus !== Object.values(WalkthroughStatuses)[Object.values(WalkthroughStatuses).length - 1]}
181 |
182 | Next
183 |
184 | {:else}
185 |
186 | Close
187 |
188 | {/if}
189 |
190 |
191 |
202 |
--------------------------------------------------------------------------------
/src/walkthrough/WalkthroughView.ts:
--------------------------------------------------------------------------------
1 | import { ItemView, WorkspaceLeaf } from "obsidian";
2 | import InboxWalkthroughComponent from "./WalkthroughView.svelte";
3 | import type InboxPlugin from "src/main";
4 | import { getFolders } from "src/obsidian/vault-helpers";
5 |
6 | export const VIEW_TYPE_WALKTHROUGH = "inbox-walkthrough-view";
7 |
8 | export class InboxWalkthroughView extends ItemView {
9 | component: InboxWalkthroughComponent;
10 | plugin: InboxPlugin;
11 |
12 | constructor(leaf: WorkspaceLeaf, plugin: InboxPlugin) {
13 | super(leaf);
14 | this.plugin = plugin;
15 | }
16 |
17 | getViewType() {
18 | return VIEW_TYPE_WALKTHROUGH;
19 | }
20 |
21 | getDisplayText() {
22 | return "Inbox Walkthrough";
23 | }
24 |
25 | getIcon() {
26 | return "info";
27 | }
28 |
29 | async onOpen() {
30 | this.component = new InboxWalkthroughComponent({
31 | target: this.contentEl,
32 | props: {
33 | app: this.app,
34 | closeWalkthroughView: () => this.closeWalkthroughView(),
35 | markdownFiles: this.app.vault.getMarkdownFiles(),
36 | folders: getFolders(this.app.vault),
37 | },
38 | });
39 | }
40 |
41 | async onClose() {
42 | this.component.$destroy();
43 | }
44 |
45 | closeWalkthroughView() {
46 | this.plugin.app.workspace.detachLeavesOfType(VIEW_TYPE_WALKTHROUGH);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/walkthrough/walkthrough-state-machine.ts:
--------------------------------------------------------------------------------
1 | import type { InboxPluginSettingsV2 } from "src/settings/InboxPluginSettingsV2";
2 | import { TrackingTypes } from "src/settings/TrackingTypes";
3 | import {
4 | WalkthroughStatuses,
5 | type WalkthroughStatus,
6 | } from "./WalkthroughStatus";
7 | import {
8 | WalkthroughActions,
9 | type WalkthroughAction,
10 | } from "./WalkthroughAction";
11 |
12 | type Machine = {
13 | initial: WalkthroughStatus;
14 | states: {
15 | [Status in WalkthroughStatuses]: {
16 | [Action in WalkthroughAction]?:
17 | | WalkthroughStatus
18 | | { [Type in TrackingTypes]: WalkthroughStatus };
19 | };
20 | };
21 | };
22 |
23 | const machine: Machine = {
24 | initial: WalkthroughStatuses.unstarted,
25 | states: {
26 | [WalkthroughStatuses.unstarted]: {
27 | [WalkthroughActions.next]:
28 | WalkthroughStatuses.setCompareFileOrFolder,
29 | },
30 | [WalkthroughStatuses.setCompareFileOrFolder]: {
31 | [WalkthroughActions.next]: {
32 | [TrackingTypes.note]: WalkthroughStatuses.setCompareType,
33 | [TrackingTypes.folder]: WalkthroughStatuses.setInboxPath,
34 | },
35 | },
36 | [WalkthroughStatuses.setCompareType]: {
37 | [WalkthroughActions.previous]:
38 | WalkthroughStatuses.setCompareFileOrFolder,
39 | [WalkthroughActions.next]: WalkthroughStatuses.setInboxPath,
40 | },
41 | [WalkthroughStatuses.setInboxPath]: {
42 | [WalkthroughActions.previous]: {
43 | [TrackingTypes.note]: WalkthroughStatuses.setCompareType,
44 | [TrackingTypes.folder]:
45 | WalkthroughStatuses.setCompareFileOrFolder,
46 | },
47 | [WalkthroughActions.next]: WalkthroughStatuses.restartObsidian,
48 | },
49 | [WalkthroughStatuses.restartObsidian]: {
50 | [WalkthroughActions.previous]: WalkthroughStatuses.setInboxPath,
51 | [WalkthroughActions.next]: WalkthroughStatuses.completed,
52 | },
53 | [WalkthroughStatuses.completed]: {
54 | [WalkthroughActions.previous]: WalkthroughStatuses.restartObsidian,
55 | },
56 | },
57 | };
58 |
59 | export function transition(
60 | state: InboxPluginSettingsV2,
61 | action: WalkthroughAction
62 | ) {
63 | const to = machine.states[state.walkthroughStatus][action];
64 | if (typeof to === "string") {
65 | state.walkthroughStatus = to;
66 | } else if (typeof to === "object") {
67 | const trackingType = state.inboxes.at(-1)?.trackingType;
68 | if (trackingType) {
69 | state.walkthroughStatus = to[trackingType];
70 | }
71 | }
72 | return state;
73 | }
74 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@tsconfig/svelte/tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["svelte", "node"],
5 | "baseUrl": ".",
6 | "inlineSources": true,
7 | "module": "ESNext",
8 | "target": "ES6",
9 | "allowJs": true,
10 | "noImplicitAny": true,
11 | "moduleResolution": "node",
12 | "importHelpers": true,
13 | "isolatedModules": true,
14 | "strictNullChecks": true,
15 | "lib": ["DOM", "ES5", "ES6", "ES7"]
16 | },
17 | "include": ["**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/version-bump.mjs:
--------------------------------------------------------------------------------
1 | import { readFileSync, writeFileSync } from "fs";
2 |
3 | const targetVersion = process.env.npm_package_version;
4 |
5 | // read minAppVersion from manifest.json and bump version to target version
6 | let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
7 | const { minAppVersion } = manifest;
8 | manifest.version = targetVersion;
9 | writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
10 |
11 | // update versions.json with target version and minAppVersion from manifest.json
12 | let versions = JSON.parse(readFileSync("versions.json", "utf8"));
13 | versions[targetVersion] = minAppVersion;
14 | writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
15 |
--------------------------------------------------------------------------------
/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "0.0.1": "0.15.0",
3 | "0.0.3": "0.15.0",
4 | "0.0.4": "0.15.0",
5 | "0.0.5": "0.15.0",
6 | "0.1.0": "0.15.0",
7 | "0.2.0": "0.15.0",
8 | "0.2.1": "0.15.0",
9 | "0.2.2": "0.15.0",
10 | "0.2.3": "0.15.0",
11 | "0.3.0": "0.15.0",
12 | "1.0.0": "0.15.0",
13 | "1.1.0": "0.15.0",
14 | "2.0.0": "0.15.0",
15 | "2.0.1": "0.15.0",
16 | "3.0.0": "0.15.0",
17 | "3.0.1": "0.15.0",
18 | "3.0.2": "0.15.0"
19 | }
20 |
--------------------------------------------------------------------------------