fix: sync completion across clients and restore Windows build

- Guard SystemTray DBus members correctly for MinGW builds\n- Let remote done override local scheduled/in-progress despite clock skew\n- Add Android start/lead reminders and lead-minute setting\n- Use expedited WorkManager for local Android changes\n- Add desktop/Android completion and reminder validation
This commit is contained in:
Misaki
2026-10-26 21:30:58 +08:00
parent 795f9730f8
commit f68b4f7c6f
22 changed files with 468 additions and 15 deletions
+63
View File
@@ -17,6 +17,7 @@ private slots:
void proposedDiffRoundTrip();
void outboxCapturesLocalChanges();
void remoteApplySuppressesOutboxAndUsesLww();
void remoteCompletionWinsOverOlderTimestamp();
};
void TestStorage::migrationCreatesSchema()
@@ -260,5 +261,67 @@ void TestStorage::remoteApplySuppressesOutboxAndUsesLww()
QCOMPARE(store.outboxCount(), 0);
}
void TestStorage::remoteCompletionWinsOverOlderTimestamp()
{
QTemporaryDir dir;
QVERIFY(dir.isValid());
SqliteStore store(dir.filePath(QStringLiteral("schedule.db")));
QString error;
QVERIFY2(store.open(&error), qPrintable(error));
const QDateTime now = QDateTime::currentDateTime();
Task task;
task.id = QStringLiteral("completion-task");
task.title = QStringLiteral("完成同步");
task.createdAt = now;
task.updatedAt = now;
task.deviceId = QStringLiteral("device-a");
QVERIFY(store.insertTask(task));
TimeBlock block;
block.id = QStringLiteral("completion-block");
block.taskId = task.id;
block.startAt = now.addSecs(3600);
block.endAt = now.addSecs(7200);
block.createdAt = now;
block.updatedAt = now;
block.deviceId = QStringLiteral("device-a");
QVERIFY(store.insertTimeBlock(block));
RemoteChange change;
change.seq = 2;
change.deviceId = QStringLiteral("device-b");
change.entityType = QStringLiteral("timeblock");
change.entityId = block.id;
change.op = QStringLiteral("upsert");
change.version = 1;
change.updatedAt = DateTimeUtils::toDb(now.addSecs(-60));
change.payload = QJsonObject{
{QStringLiteral("id"), block.id},
{QStringLiteral("task_id"), task.id},
{QStringLiteral("start_at"), DateTimeUtils::toDb(block.startAt)},
{QStringLiteral("end_at"), DateTimeUtils::toDb(block.endAt)},
{QStringLiteral("granularity"), 15},
{QStringLiteral("splittable"), 1},
{QStringLiteral("breakable"), 1},
{QStringLiteral("status"), QStringLiteral("done")},
{QStringLiteral("done_at"), DateTimeUtils::toDb(now.addSecs(-60))},
{QStringLiteral("created_at"), DateTimeUtils::toDb(block.createdAt)},
{QStringLiteral("updated_at"), DateTimeUtils::toDb(now.addSecs(-60))},
{QStringLiteral("version"), 1},
{QStringLiteral("device_id"), QStringLiteral("device-b")},
};
QVERIFY(store.beginTransaction());
QVERIFY(store.setRemoteApplySuppressed(true));
QVERIFY(store.applyRemoteChange(change));
QVERIFY(store.setRemoteApplySuppressed(false));
QVERIFY(store.commit());
const auto updated = store.timeBlockById(block.id);
QVERIFY(updated.has_value());
QCOMPARE(updated->status, QStringLiteral("done"));
QVERIFY(updated->doneAt.has_value());
}
QTEST_GUILESS_MAIN(TestStorage)
#include "test_storage.moc"