feat: Auto sync label from web socket

This commit is contained in:
dab246
2026-02-03 19:20:52 +07:00
committed by Dat H. Pham
parent c49e48ae1b
commit 9c211c05ef
17 changed files with 536 additions and 24 deletions
@@ -243,4 +243,28 @@ class LabelUtils {
return name;
}
}
static void applyLabelChanges({
required List<Label> currentLabels,
required List<Label> created,
required List<Label> updated,
required List<Id> destroyedIds,
}) {
final idsToRemove = {
...destroyedIds,
...updated.map((label) => label.id),
};
if (idsToRemove.isNotEmpty) {
currentLabels.removeWhere((label) => idsToRemove.contains(label.id));
}
if (created.isNotEmpty) {
currentLabels.addAll(created);
}
if (updated.isNotEmpty) {
currentLabels.addAll(updated);
}
}
}