MCPcopy Index your code
hub / github.com/DeepNotesApp/DeepNotes / updateCurrentPath

Method updateCurrentPath

apps/client/src/code/pages/pages.ts:196–249  ·  view source on GitHub ↗
(pageId: string, parentPageId?: string)

Source from the content-addressed store, hash-verified

194 }
195
196 async updateCurrentPath(pageId: string, parentPageId?: string) {
197 if (this.react.pathPageIds.find((pathPageId) => pathPageId === pageId)) {
198 // New page exists in path
199 // Do nothing
200
201 return;
202 }
203
204 const parentPageIndex = this.react.pathPageIds.findIndex(
205 (pagePageId) => pagePageId === parentPageId,
206 );
207
208 if (parentPageIndex >= 0) {
209 // Parent page exists in path
210 // Insert new page in front of parent page
211
212 this.react.pathPageIds.splice(parentPageIndex + 1);
213 this.react.pathPageIds.push(pageId);
214
215 return;
216 }
217
218 // Parent page does not exist in path
219 // Try to load current path
220
221 if (authStore().loggedIn) {
222 try {
223 this.react.pathPageIds =
224 await trpcClient.users.pages.getCurrentPath.query({
225 initialPageId: pageId,
226 });
227
228 return;
229 } catch (error) {
230 mainLogger.error(error);
231 }
232 }
233
234 // Couldn't load current path
235 // Set new page as root page
236
237 if (authStore().loggedIn) {
238 this.react.pathPageIds = [
239 await internals.realtime.hget(
240 'group',
241 internals.personalGroupId,
242 'main-page-id',
243 ),
244 pageId,
245 ];
246 } else {
247 this.react.pathPageIds = [pageId];
248 }
249 }
250
251 async goToPage(
252 pageId: string,

Callers 1

setupPageMethod · 0.95

Calls 1

hgetMethod · 0.45

Tested by

no test coverage detected