Change: show loaded and total
This commit is contained in:
parent
1b02c5b85b
commit
d88bd092e1
|
@ -10,7 +10,7 @@ const sync = (() => {
|
|||
const status = {
|
||||
state: 'disconnected',
|
||||
syncing: false,
|
||||
syncTarget: null,
|
||||
progress: null,
|
||||
currentDriveName: null
|
||||
};
|
||||
let currentDrive;
|
||||
|
@ -73,14 +73,14 @@ const sync = (() => {
|
|||
getStatus: () => status
|
||||
};
|
||||
|
||||
function onProgress(type, change) {
|
||||
if (type === 'syncStart') {
|
||||
function onProgress(e) {
|
||||
if (e.phase === 'start') {
|
||||
status.syncing = true;
|
||||
} else if (type === 'syncEnd') {
|
||||
} else if (e.phase === 'end') {
|
||||
status.syncing = false;
|
||||
status.syncTarget = null;
|
||||
status.progress = null;
|
||||
} else {
|
||||
status.syncTarget = [type, change];
|
||||
status.progress = e;
|
||||
}
|
||||
emitStatusChange();
|
||||
}
|
||||
|
|
|
@ -117,12 +117,9 @@ document.onclick = e => {
|
|||
function getStatusText() {
|
||||
// FIXME: i18n
|
||||
if (status.syncing) {
|
||||
if (status.syncTarget) {
|
||||
const [type, change] = status.syncTarget;
|
||||
if (type === 'syncPull') {
|
||||
return `pulling data ${change._id}`;
|
||||
}
|
||||
return `pushing data ${change._id}`;
|
||||
if (status.progress) {
|
||||
const {phase, loaded, total} = status.syncTarget;
|
||||
return `${phase}ing style ${loaded + 1} of ${total}`;
|
||||
}
|
||||
return 'syncing...';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user