mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feature(mobile): Hardening synchronization mechanism + Pull to refresh (#2085)
* fix(mobile): allow syncing duplicate local IDs * enable to run isar unit tests on CI * serialize sync operations, add pull to refresh on timeline --------- Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com>
This commit is contained in:
parent
1a94530935
commit
cae37657e9
21 changed files with 653 additions and 249 deletions
|
|
@ -20,7 +20,7 @@ class ImmichLogger {
|
|||
static final ImmichLogger _instance = ImmichLogger._internal();
|
||||
final maxLogEntries = 200;
|
||||
final Isar _db = Isar.getInstance()!;
|
||||
final List<LoggerMessage> _msgBuffer = [];
|
||||
List<LoggerMessage> _msgBuffer = [];
|
||||
Timer? _timer;
|
||||
|
||||
factory ImmichLogger() => _instance;
|
||||
|
|
@ -41,7 +41,12 @@ class ImmichLogger {
|
|||
final msgCount = _db.loggerMessages.countSync();
|
||||
if (msgCount > maxLogEntries) {
|
||||
final numberOfEntryToBeDeleted = msgCount - maxLogEntries;
|
||||
_db.loggerMessages.where().limit(numberOfEntryToBeDeleted).deleteAll();
|
||||
_db.writeTxn(
|
||||
() => _db.loggerMessages
|
||||
.where()
|
||||
.limit(numberOfEntryToBeDeleted)
|
||||
.deleteAll(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +68,9 @@ class ImmichLogger {
|
|||
|
||||
void _flushBufferToDatabase() {
|
||||
_timer = null;
|
||||
_db.writeTxnSync(() => _db.loggerMessages.putAllSync(_msgBuffer));
|
||||
_msgBuffer.clear();
|
||||
final buffer = _msgBuffer;
|
||||
_msgBuffer = [];
|
||||
_db.writeTxn(() => _db.loggerMessages.putAll(buffer));
|
||||
}
|
||||
|
||||
void clearLogs() {
|
||||
|
|
@ -111,7 +117,7 @@ class ImmichLogger {
|
|||
void flush() {
|
||||
if (_timer != null) {
|
||||
_timer!.cancel();
|
||||
_flushBufferToDatabase();
|
||||
_db.writeTxnSync(() => _db.loggerMessages.putAllSync(_msgBuffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue