mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-28 17:08:29 +01:00
Keep a profile save away from the timezone column
This commit is contained in:
@@ -44,12 +44,14 @@ class UserProfile {
|
||||
int get defaultWeightUnitId => isMetric ? WEIGHT_UNIT_KG : WEIGHT_UNIT_LB;
|
||||
|
||||
/// Drift companion for local UPDATE writes routed through PowerSync.
|
||||
///
|
||||
/// Only the columns the profile form edits: the timezone column belongs to
|
||||
/// TimezoneSync, and a full write would clear what another client reported.
|
||||
UserProfileTableCompanion toCompanion() {
|
||||
return UserProfileTableCompanion(
|
||||
id: drift.Value(id),
|
||||
weightUnitStr: drift.Value(weightUnitStr),
|
||||
height: drift.Value(height),
|
||||
timeZone: drift.Value(timeZone),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,18 @@ void main() {
|
||||
expect(row.height, 178);
|
||||
});
|
||||
|
||||
test('leaves the reported timezone alone', () async {
|
||||
// The column belongs to TimezoneSync; the server rejects it as null,
|
||||
// taking the rest of the profile write down with it
|
||||
await seed();
|
||||
await repo.updateTimeZoneDrift(1, 'Pacific/Auckland');
|
||||
|
||||
await repo.editLocalDrift(UserProfile(id: 1, weightUnitStr: 'lb'));
|
||||
|
||||
final row = await db.select(db.userProfileTable).getSingle();
|
||||
expect(row.timeZone, 'Pacific/Auckland');
|
||||
});
|
||||
|
||||
test('clears the height when the profile has none', () async {
|
||||
// The server allows a profile without one, so an emptied field has to
|
||||
// reach the column as NULL rather than leaving the old value standing
|
||||
|
||||
Reference in New Issue
Block a user