(view: SheetViewMode)
| 618 | }; |
| 619 | |
| 620 | const worksheetsForView = (view: SheetViewMode): Worksheet[] => { |
| 621 | if (view !== "my" && view !== "shared") return []; |
| 622 | const filter = useSheetContextStore.getState().filter; |
| 623 | const project = getSQLEditorEditorState().project; |
| 624 | // SQLEditorLayout awaits `loadCurrentUser()` in its bootstrap, so by the |
| 625 | // time worksheets land here the app-store `currentUser` is populated. |
| 626 | // Empty `email` falls through to creator `"users/"`, which matches no |
| 627 | // worksheets — they'd render as Shared rather than Mine, same fallback |
| 628 | // the previous Pinia path had. |
| 629 | const email = useAppStore.getState().currentUser?.email ?? ""; |
| 630 | const creator = `users/${email}`; |
| 631 | let list = useAppStore |
| 632 | .getState() |
| 633 | .worksheetList() |
| 634 | .filter((sheet) => { |
| 635 | if (sheet.project !== project) return false; |
| 636 | const mine = sheet.creator === creator; |
| 637 | return view === "my" ? mine : !mine; |
| 638 | }); |
| 639 | if (filter.onlyShowStarred) { |
| 640 | list = list.filter((sheet) => sheet.starred); |
| 641 | } |
| 642 | return list; |
| 643 | }; |
| 644 | |
| 645 | const sheetLikeItemsForView = (view: SheetViewMode): WorksheetLikeItem[] => { |
| 646 | if (view === "draft") { |
no test coverage detected