sync: make tags & colors syncable

This commit is contained in:
Abdullah Atta
2023-09-09 20:26:51 +05:00
parent fc757674a9
commit 8bbb4d0b9e
4 changed files with 18 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ namespace Notesnook.API.Accessors
public SyncItemsRepository<Content> Contents { get; }
public SyncItemsRepository<Setting> Settings { get; }
public SyncItemsRepository<Attachment> Attachments { get; }
public SyncItemsRepository<Color> Colors { get; }
public SyncItemsRepository<Tag> Tags { get; }
public Repository<UserSettings> UsersSettings { get; }
public Repository<Monograph> Monographs { get; }
@@ -45,6 +47,8 @@ namespace Notesnook.API.Accessors
SyncItemsRepository<Shortcut> _shortcuts,
SyncItemsRepository<Relation> _relations,
SyncItemsRepository<Reminder> _reminders,
SyncItemsRepository<Color> _colors,
SyncItemsRepository<Tag> _tags,
Repository<UserSettings> _usersSettings,
Repository<Monograph> _monographs)
{
@@ -58,6 +62,8 @@ namespace Notesnook.API.Accessors
Shortcuts = _shortcuts;
Reminders = _reminders;
Relations = _relations;
Colors = _colors;
Tags = _tags;
}
}
}

View File

@@ -34,6 +34,8 @@ namespace Notesnook.API.Interfaces
SyncItemsRepository<Content> Contents { get; }
SyncItemsRepository<Setting> Settings { get; }
SyncItemsRepository<Attachment> Attachments { get; }
SyncItemsRepository<Color> Colors { get; }
SyncItemsRepository<Tag> Tags { get; }
Repository<UserSettings> UsersSettings { get; }
Repository<Monograph> Monographs { get; }
}

View File

@@ -124,4 +124,10 @@ namespace Notesnook.API.Models
[BsonCollection("notesnook", "shortcuts")]
public class Shortcut : SyncItem { }
[BsonCollection("notesnook", "tags")]
public class Tag : SyncItem { }
[BsonCollection("notesnook", "colors")]
public class Color : SyncItem { }
}

View File

@@ -175,6 +175,8 @@ namespace Notesnook.API.Services
Repositories.Attachments.DeleteByUserId(userId);
Repositories.Reminders.DeleteByUserId(userId);
Repositories.Relations.DeleteByUserId(userId);
Repositories.Colors.DeleteByUserId(userId);
Repositories.Tags.DeleteByUserId(userId);
Repositories.UsersSettings.Delete((u) => u.UserId == userId);
Repositories.Monographs.DeleteMany((m) => m.UserId == userId);
@@ -216,6 +218,8 @@ namespace Notesnook.API.Services
Repositories.Attachments.DeleteByUserId(userId);
Repositories.Reminders.DeleteByUserId(userId);
Repositories.Relations.DeleteByUserId(userId);
Repositories.Colors.DeleteByUserId(userId);
Repositories.Tags.DeleteByUserId(userId);
Repositories.Monographs.DeleteMany((m) => m.UserId == userId);
if (!await unit.Commit()) return false;