feat: Refactor note decryption method and update category handling for improved clarity
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:notas/data/note_encryption.dart';
|
||||
import 'package:notas/models/note.dart';
|
||||
import 'package:notas/models/category.dart';
|
||||
import 'dart:convert';
|
||||
@@ -108,13 +109,13 @@ class SyncCategoryPayload {
|
||||
final int? iconCodePoint;
|
||||
final DateTime updatedAt;
|
||||
|
||||
factory SyncCategoryPayload.fromCategory(
|
||||
static Future<SyncCategoryPayload> fromCategory(
|
||||
Category category, {
|
||||
required String encryptedName,
|
||||
}) {
|
||||
required String masterKey,
|
||||
}) async {
|
||||
return SyncCategoryPayload(
|
||||
id: category.id,
|
||||
encryptedName: encryptedName,
|
||||
encryptedName: await NoteEncryption.encryptNote(category.name, masterKey),
|
||||
serverVersion: category.serverVersion,
|
||||
isDeleted: category.isDeleted,
|
||||
colorValue: category.colorValue,
|
||||
@@ -249,10 +250,10 @@ class SyncCategoryResponse {
|
||||
);
|
||||
}
|
||||
|
||||
Category toCategory({required String name}) {
|
||||
Future<Category> toCategory({required String masterKey}) async {
|
||||
return Category(
|
||||
id: id,
|
||||
name: name,
|
||||
name: await NoteEncryption.decrypt(encryptedName, masterKey),
|
||||
serverVersion: serverVersion,
|
||||
isDeleted: isDeleted,
|
||||
colorValue: colorValue,
|
||||
|
||||
Reference in New Issue
Block a user