Skip to content

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

core: fix typing errors

Abdullah Atta21a7c64b0bd9
diff --git a/packages/core/src/collections/settings.ts b/packages/core/src/collections/settings.ts
index 746352de6..e852a391d 100644
--- a/packages/core/src/collections/settings.ts
+++ b/packages/core/src/collections/settings.ts
@@ -26,7 +26,8 @@ import {
GroupingKey,
SettingsItem,
ToolbarConfig,
- TrashCleanupInterval
+ TrashCleanupInterval,
+ isDeleted
} from "../types";
import { ICollection } from "./collection";
import { TimeFormat } from "../utils/date";
@@ -58,18 +59,25 @@ class Settings implements ICollection {
async merge(remoteItem: SettingsItem, lastSynced: number) {
if (this.settings.dateModified > lastSynced) {
- this.settings.id = remoteItem.id;
- this.settings.groupOptions = {
- ...this.settings.groupOptions,
- ...remoteItem.groupOptions
- };
- this.settings.toolbarConfig = {
- ...this.settings.toolbarConfig,
- ...remoteItem.toolbarConfig
- };
- this.settings.aliases = {
- ...this.settings.aliases,
- ...remoteItem.aliases
+ this.settings = {
+ ...this.settings,
+ ...(isDeleted(remoteItem)
+ ? {}
+ : {
+ ...remoteItem,
+ groupOptions: {
+ ...this.settings.groupOptions,
+ ...remoteItem.groupOptions
+ },
+ toolbarConfig: {
+ ...this.settings.toolbarConfig,
+ ...remoteItem.toolbarConfig
+ },
+ aliases: {
+ ...this.settings.aliases,
+ ...remoteItem.aliases
+ }
+ })
};
this.settings.dateModified = Date.now();
} else {
diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts
index 27e4d4aae..e96ad9008 100644
--- a/packages/core/src/types.ts
+++ b/packages/core/src/types.ts
@@ -76,6 +76,7 @@ export type GroupableItem = ValueOf<
| "relation"
| "tiny"
| "tiptap"
+ | "content"
| "session"
| "sessioncontent"
| "settings"
@@ -290,13 +291,16 @@ export type DefaultNotebook = { id: string; topic?: string };
export interface SettingsItem extends BaseItem<"settings"> {
groupOptions?: Partial<Record<GroupingKey, GroupOptions>>;
toolbarConfig?: Record<string, ToolbarConfig>;
- aliases?: Record<string, string>;
trashCleanupInterval?: TrashCleanupInterval;
titleFormat?: string;
timeFormat?: TimeFormat;
dateFormat?: string;
defaultNotebook?: DefaultNotebook;
+ /**
+ * @deprecated only kept here for migration purposes.
+ */
+ aliases?: Record<string, string>;
/**
* @deprecated only kept here for migration purposes.
*/