A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix note history tests
Abdullah Attaadd2d8af9b43
diff --git a/apps/web/__e2e__/models/note-properties.model.ts b/apps/web/__e2e__/models/note-properties.model.tsindex 760b11944..1b06fc781 100644--- a/apps/web/__e2e__/models/note-properties.model.ts+++ b/apps/web/__e2e__/models/note-properties.model.ts@@ -348,6 +348,7 @@ class SessionHistoryItemModel {await fillPasswordDialog(this.page, password);}await this.previewNotice.waitFor();+ await this.properties.close();}async isLocked() {diff --git a/apps/web/src/components/attachment/index.tsx b/apps/web/src/components/attachment/index.tsxindex 40801afd8..3e99a29a9 100644--- a/apps/web/src/components/attachment/index.tsx+++ b/apps/web/src/components/attachment/index.tsx@@ -170,11 +170,7 @@ export function Attachment({<AttachmentErrorcolor={"icon-error"}size={16}- title={- typeof attachment.failed === "object"- ? attachment.failed.toString()- : attachment.failed- }+ title={processing?.failed || item.failed}/>) : processing?.working ? (<Loading size={16} />diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsxindex e1ff93d51..00ef54d70 100644--- a/apps/web/src/components/note/index.tsx+++ b/apps/web/src/components/note/index.tsx@@ -147,10 +147,9 @@ function Note(props: NoteProps) {body={note.headline as string}onKeyPress={async (e) => {if (e.key === "Delete") {- const selectedItems = selectionStore- .get()- .selectedItems.filter((i) => i.type === item.type && i !== item);- await Multiselect.moveNotesToTrash([item, ...selectedItems]);+ // @ts-expect-error write tests for this+ const selectedItems = selectionStore.get().selectedItems;+ await Multiselect.moveNotesToTrash([item.id, ...selectedItems]);}}}colors={{diff --git a/apps/web/src/components/properties/index.tsx b/apps/web/src/components/properties/index.tsxindex b06257cb7..8bf101c47 100644--- a/apps/web/src/components/properties/index.tsx+++ b/apps/web/src/components/properties/index.tsx@@ -265,8 +265,7 @@ function Notebooks({ noteId }: { noteId: string }) {.selector.sorted(db.settings.getGroupOptions("notebooks")));- if (result.status !== "fulfilled" || result.value.ids.length <= 0)- return null;+ if (result.status !== "fulfilled" || result.value.length <= 0) return null;return (<Section title="Notebooks">@@ -274,7 +273,7 @@ function Notebooks({ noteId }: { noteId: string }) {mode="fixed"estimatedSize={50}getItemKey={(index) => result.value.key(index)}- items={result.value.ids}+ items={result.value.placeholders}renderItem={({ index }) => (<ResolvedItem index={index} items={result.value} type="notebook">{({ item, data }) => (@@ -292,8 +291,7 @@ function Reminders({ noteId }: { noteId: string }) {.from({ id: noteId, type: "note" }, "reminder").selector.sorted(db.settings.getGroupOptions("reminders")));- if (result.status !== "fulfilled" || result.value.ids.length <= 0)- return null;+ if (result.status !== "fulfilled" || result.value.length <= 0) return null;return (<Section title="Reminders">@@ -301,7 +299,7 @@ function Reminders({ noteId }: { noteId: string }) {mode="fixed"estimatedSize={54}getItemKey={(index) => result.value.key(index)}- items={result.value.ids}+ items={result.value.placeholders}renderItem={({ index }) => (<ResolvedItem index={index} items={result.value} type="reminder">{({ item, data }) => (@@ -319,15 +317,14 @@ function Attachments({ noteId }: { noteId: string }) {.ofNote(noteId, "all").sorted({ sortBy: "dateCreated", sortDirection: "desc" }));- if (result.status !== "fulfilled" || result.value.ids.length <= 0)- return null;+ if (result.status !== "fulfilled" || result.value.length <= 0) return null;return (<Section title="Attachments"><VirtualizedTableestimatedSize={30}getItemKey={(index) => result.value.key(index)}- items={result.value.ids}+ items={result.value.placeholders}header={<></>}renderRow={({ index }) => (<ResolvedItem index={index} type="attachment" items={result.value}>@@ -354,8 +351,7 @@ function SessionHistory({.get(noteId).sorted({ sortBy: "dateModified", sortDirection: "desc" }));- if (result.status !== "fulfilled" || result.value.ids.length <= 0)- return null;+ if (result.status !== "fulfilled" || result.value.length <= 0) return null;return (<Section@@ -366,7 +362,7 @@ function SessionHistory({mode="fixed"estimatedSize={28}getItemKey={(index) => result.value.key(index)}- items={result.value.ids}+ items={result.value.placeholders}renderItem={({ index }) => (<ResolvedItem type="session" index={index} items={result.value}>{({ item }) => (diff --git a/apps/web/src/dialogs/add-tags-dialog.tsx b/apps/web/src/dialogs/add-tags-dialog.tsxindex f708bcfe8..90f0a89c3 100644--- a/apps/web/src/dialogs/add-tags-dialog.tsx+++ b/apps/web/src/dialogs/add-tags-dialog.tsx@@ -112,7 +112,7 @@ function AddTagsDialog(props: AddTagsDialogProps) {getItemKey={(index) => tags.key(index)}mode="fixed"estimatedSize={30}- items={tags.ids}+ items={tags.placeholders}sx={{ mt: 2 }}itemGap={5}placeholders={{diff --git a/apps/web/src/dialogs/attachments-dialog.tsx b/apps/web/src/dialogs/attachments-dialog.tsxindex b2ec74eaa..1e9fd7667 100644--- a/apps/web/src/dialogs/attachments-dialog.tsx+++ b/apps/web/src/dialogs/attachments-dialog.tsx@@ -320,7 +320,7 @@ function AttachmentsDialog({ onClose }: AttachmentsDialogProps) {mode="fixed"estimatedSize={30}getItemKey={(index) => attachments.key(index)}- items={attachments.ids}+ items={attachments.placeholders}context={{isSelected: (id: string) => selected.indexOf(id) > -1,select: (id: string) => {diff --git a/apps/web/src/utils/importer.ts b/apps/web/src/utils/importer.tsindex 249d6c71c..562cacc0c 100644--- a/apps/web/src/utils/importer.ts+++ b/apps/web/src/utils/importer.ts@@ -70,7 +70,8 @@ async function processAttachment(attachments: Record<string, any>) {const name = path.basename(entry.name);- if (!name || attachments[name] || db.attachments?.exists(name)) return;+ if (!name || attachments[name] || (await db.attachments?.exists(name)))+ return;const { hashBuffer, writeEncryptedFile } = await import("../interfaces/fs");@@ -92,7 +93,8 @@ async function processNote(entry: ZipEntry, attachments: Record<string, any>) {const note = await fileToJson<Note>(entry);for (const attachment of note.attachments || []) {const cipherData = attachments[attachment.hash];- if (!cipherData || db.attachments?.exists(attachment.hash)) continue;+ if (!cipherData || (await db.attachments?.exists(attachment.hash)))+ continue;await db.attachments?.add({...cipherData,diff --git a/packages/core/src/utils/virtualized-grouping.ts b/packages/core/src/utils/virtualized-grouping.tsindex d3c847263..8d25000d2 100644--- a/packages/core/src/utils/virtualized-grouping.ts+++ b/packages/core/src/utils/virtualized-grouping.ts@@ -28,6 +28,7 @@ type Batch<T> = {export class VirtualizedGrouping<T> {private cache: Map<number, Batch<T>> = new Map();private pending: Map<number, Promise<Batch<T>>> = new Map();+ private _placeholders: boolean[] = [];constructor(readonly length: number,@@ -43,6 +44,13 @@ export class VirtualizedGrouping<T> {readonly groups?: () => Promise<{ index: number; group: GroupHeader }[]>) {}+ get placeholders() {+ if (this._placeholders.length !== this.length) {+ this._placeholders = new Array(this.length).fill(true);+ }+ return this._placeholders;+ }+key(index: number) {return `${index}`;}