Skip to content

Commit 01a1b48

Browse files
committed
Make sync result message more verbose and explicit.
1 parent 7b27be1 commit 01a1b48

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

frontend/viewer/src/project/SyncDialog.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,20 @@
5757
latestSyncedCommitDate = undefined;
5858
}
5959
60-
async function syncLexboxToFlex() {
60+
async function syncLexboxToFlex(flexToLexboxCount: number, lexboxToFlexCount: number) {
6161
let safeToCloseDialog = false;
6262
6363
const syncPromise = service.triggerFwHeadlessSync();
6464
AppNotification.promise(syncPromise, {
6565
loading: $t`Synchronizing FieldWorks Lite and FieldWorks...`,
6666
success: (result) => {
67+
const fwdataCommitsText = $plural(lexboxToFlexCount ?? 0, {one: '# commit', other: '# commits'});
68+
const crdtCommitsText = $plural(flexToLexboxCount ?? 0, {one: '# commit', other: '# commits'});
6769
const fwdataChangesText = $plural(result.syncResult?.fwdataChanges ?? 0, {one: '# change', other: '# changes'});
6870
const crdtChangesText = $plural(result.syncResult?.crdtChanges ?? 0, {one: '# change', other: '# changes'});
69-
return $t`${fwdataChangesText} synced to FieldWorks. ${crdtChangesText} synced to FieldWorks Lite.`;
71+
return $t`Synced ${fwdataCommitsText} to FieldWorks, which resulted in ${fwdataChangesText} `
72+
+ $t`and ${crdtCommitsText} to FieldWorks Lite, which resulted in ${crdtChangesText}. `
73+
+ $t`(Changes to FieldWorks Lite can be caused by new releases that include more fields/data from FieldWorks).`;
7074
},
7175
error: (error) => $t`Failed to synchronize.` + '\n' + (error as Error).message,
7276
// TODO: Custom component that can expand or collapse the stacktrace

frontend/viewer/src/project/sync/FwLiteToFwMergeDetails.svelte

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
loadingSyncLexboxToFlex: boolean,
3131
loadingSyncLexboxToLocal: boolean,
3232
canSyncLexboxToFlex?: boolean,
33-
syncLexboxToFlex?: () => Promise<void>
33+
syncLexboxToFlex?: (flexToLexboxCount: number, lexboxToFlexCount: number) => Promise<void>
3434
onLoginStatusChange?: (status: 'logged-in' | 'logged-out') => void;
3535
} = $props();
3636
const lastFlexSyncDate = $derived(remoteStatus?.lastMercurialCommitDate ? new Date(remoteStatus.lastMercurialCommitDate) : undefined);
3737
const lastFwLiteSyncDate = $derived(remoteStatus?.lastCrdtCommitDate ? new Date(remoteStatus.lastCrdtCommitDate) : undefined);
3838
let lexboxToFlexCount = $derived(remoteStatus?.pendingCrdtChanges ?? '?');
3939
let flexToLexboxCount = $derived(remoteStatus?.pendingMercurialChanges ?? '?');
4040
41-
function onSyncLexboxToFlex() {
41+
function onSyncLexboxToFlex(flexToLexboxCount: number, lexboxToFlexCount: number) {
4242
loadingSyncLexboxToFlex = true;
43-
void syncLexboxToFlex().finally(() => {
43+
void syncLexboxToFlex(flexToLexboxCount, lexboxToFlexCount).finally(() => {
4444
loadingSyncLexboxToFlex = false;
4545
});
4646
}
@@ -72,8 +72,9 @@
7272
<SyncArrow dir="left" tailLength={120} size={1.25}/>
7373
<Button
7474
loading={loadingSyncLexboxToFlex}
75-
disabled={loadingSyncLexboxToLocal || !canSyncLexboxToFlex || !remoteStatus}
76-
onclick={onSyncLexboxToFlex}
75+
disabled={loadingSyncLexboxToLocal || !canSyncLexboxToFlex || !remoteStatus
76+
|| (typeof flexToLexboxCount !== 'number' || typeof lexboxToFlexCount !== 'number')}
77+
onclick={() => onSyncLexboxToFlex(flexToLexboxCount as number, lexboxToFlexCount as number)}
7778
icon="i-mdi-sync"
7879
iconProps={{ class: 'size-5' }}>
7980
{$t`Sync`}

frontend/viewer/src/project/sync/SyncStatusPrimitive.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
projectCode?: string;
2323
latestSyncedCommitDate?: string;
2424
canSyncLexboxToFlex?: boolean;
25-
syncLexboxToFlex?: () => Promise<void>;
25+
syncLexboxToFlex?: (flexToLexboxCount: number, lexboxToFlexCount: number) => Promise<void>;
2626
syncLexboxToLocal?: () => Promise<void>;
2727
onLoginStatusChange?: (status: 'logged-in' | 'logged-out') => void;
2828
}

0 commit comments

Comments
 (0)