From 87815310424e4b195b78821bcbc4743992ff5c31 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 5 Mar 2024 10:22:51 +0500 Subject: [PATCH] sync: add new repositories for vault & settings --- Notesnook.API/Accessors/SyncItemsRepositoryAccessor.cs | 5 +++++ Notesnook.API/Interfaces/ISyncItemsRepositoryAccessor.cs | 2 ++ Notesnook.API/Models/SyncItem.cs | 6 ++++++ Notesnook.API/Services/UserService.cs | 3 +++ 4 files changed, 16 insertions(+) diff --git a/Notesnook.API/Accessors/SyncItemsRepositoryAccessor.cs b/Notesnook.API/Accessors/SyncItemsRepositoryAccessor.cs index 07933c7..c686636 100644 --- a/Notesnook.API/Accessors/SyncItemsRepositoryAccessor.cs +++ b/Notesnook.API/Accessors/SyncItemsRepositoryAccessor.cs @@ -33,8 +33,10 @@ namespace Notesnook.API.Accessors public SyncItemsRepository Reminders { get; } public SyncItemsRepository Contents { get; } public SyncItemsRepository LegacySettings { get; } + public SyncItemsRepository Settings { get; } public SyncItemsRepository Attachments { get; } public SyncItemsRepository Colors { get; } + public SyncItemsRepository Vaults { get; } public SyncItemsRepository Tags { get; } public Repository UsersSettings { get; } public Repository Monographs { get; } @@ -43,11 +45,13 @@ namespace Notesnook.API.Accessors SyncItemsRepository _notebooks, SyncItemsRepository _content, SyncItemsRepository _legacySettings, + SyncItemsRepository _settings, SyncItemsRepository _attachments, SyncItemsRepository _shortcuts, SyncItemsRepository _relations, SyncItemsRepository _reminders, SyncItemsRepository _colors, + SyncItemsRepository _vaults, SyncItemsRepository _tags, Repository _usersSettings, Repository _monographs) @@ -64,6 +68,7 @@ namespace Notesnook.API.Accessors Reminders = _reminders; Relations = _relations; Colors = _colors; + Vaults = _vaults; Tags = _tags; } } diff --git a/Notesnook.API/Interfaces/ISyncItemsRepositoryAccessor.cs b/Notesnook.API/Interfaces/ISyncItemsRepositoryAccessor.cs index 2131e44..fbbcb44 100644 --- a/Notesnook.API/Interfaces/ISyncItemsRepositoryAccessor.cs +++ b/Notesnook.API/Interfaces/ISyncItemsRepositoryAccessor.cs @@ -34,7 +34,9 @@ namespace Notesnook.API.Interfaces SyncItemsRepository Contents { get; } SyncItemsRepository LegacySettings { get; } SyncItemsRepository Attachments { get; } + SyncItemsRepository Settings { get; } SyncItemsRepository Colors { get; } + SyncItemsRepository Vaults { get; } SyncItemsRepository Tags { get; } Repository UsersSettings { get; } Repository Monographs { get; } diff --git a/Notesnook.API/Models/SyncItem.cs b/Notesnook.API/Models/SyncItem.cs index f4cf969..1416f22 100644 --- a/Notesnook.API/Models/SyncItem.cs +++ b/Notesnook.API/Models/SyncItem.cs @@ -110,6 +110,9 @@ namespace Notesnook.API.Models } = Algorithms.Default; } + [MessagePack.MessagePackObject] + public class SettingItem : SyncItem { } + [MessagePack.MessagePackObject] public class Attachment : SyncItem { } @@ -139,4 +142,7 @@ namespace Notesnook.API.Models [MessagePack.MessagePackObject] public class Color : SyncItem { } + + [MessagePack.MessagePackObject] + public class Vault : SyncItem { } } diff --git a/Notesnook.API/Services/UserService.cs b/Notesnook.API/Services/UserService.cs index 9e6e2a8..0a30c1b 100644 --- a/Notesnook.API/Services/UserService.cs +++ b/Notesnook.API/Services/UserService.cs @@ -167,7 +167,9 @@ namespace Notesnook.API.Services { var cc = new CancellationTokenSource(); + Repositories.Settings.DeleteByUserId(userId); Repositories.LegacySettings.DeleteByUserId(userId); + Repositories.Vaults.DeleteByUserId(userId); if (!Constants.IS_SELF_HOSTED) { @@ -210,6 +212,7 @@ namespace Notesnook.API.Services Repositories.Relations.DeleteByUserId(userId); Repositories.Colors.DeleteByUserId(userId); Repositories.Tags.DeleteByUserId(userId); + Repositories.Vaults.DeleteByUserId(userId); Repositories.Monographs.DeleteMany((m) => m.UserId == userId); if (!await unit.Commit()) return false;