Incremental local loading, sync status on password wizard
This commit is contained in:
@@ -208,7 +208,7 @@ class AccountMenu {
|
||||
var message = `Import complete. ${errorCount} items were not imported because there was an error decrypting them. Make sure the password is correct and try again.`;
|
||||
alert(message);
|
||||
} else {
|
||||
alert("Your data was successfully imported.")
|
||||
alert("Your data has been successfully imported.")
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
|
||||
@@ -20,6 +20,7 @@ class PasswordWizard {
|
||||
$scope.$destroy();
|
||||
}
|
||||
|
||||
$scope.syncStatus = syncManager.syncStatus;
|
||||
$scope.formData = {};
|
||||
|
||||
const IntroStep = 0;
|
||||
@@ -118,7 +119,7 @@ class PasswordWizard {
|
||||
$scope.formData.processing = passwordSuccess;
|
||||
|
||||
if(passwordSuccess) {
|
||||
$scope.formData.status = "Encrypting data with new keys...";
|
||||
$scope.formData.status = "Encrypting and syncing data with new keys...";
|
||||
|
||||
$scope.resyncData((syncSuccess) => {
|
||||
$scope.formData.statusError = !syncSuccess;
|
||||
|
||||
@@ -399,7 +399,9 @@ class ComponentManager {
|
||||
for(let handler of this.handlersForArea(component.area)) {
|
||||
if(handler.contextRequestHandler) {
|
||||
var itemInContext = handler.contextRequestHandler(component);
|
||||
this.sendContextItemInReply(component, itemInContext, message);
|
||||
if(itemInContext) {
|
||||
this.sendContextItemInReply(component, itemInContext, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bind(this))
|
||||
|
||||
@@ -42,12 +42,34 @@ class SyncManager {
|
||||
})
|
||||
}
|
||||
|
||||
loadLocalItems(callback) {
|
||||
var params = this.storageManager.getAllModels((items) => {
|
||||
this.handleItemsResponse(items, null, ModelManager.MappingSourceLocalRetrieved).then((items) => {
|
||||
Item.sortItemsByDate(items);
|
||||
callback(items);
|
||||
})
|
||||
async loadLocalItems(callback) {
|
||||
this.storageManager.getAllModels((items) => {
|
||||
// break it up into chunks to make interface more responsive for large item counts
|
||||
let total = items.length;
|
||||
let iteration = 50;
|
||||
var current = 0;
|
||||
var processed = [];
|
||||
|
||||
var completion = () => {
|
||||
Item.sortItemsByDate(processed);
|
||||
callback(processed);
|
||||
}
|
||||
|
||||
var decryptNext = async () => {
|
||||
var subitems = items.slice(current, current + iteration);
|
||||
var processedSubitems = await this.handleItemsResponse(subitems, null, ModelManager.MappingSourceLocalRetrieved);
|
||||
processed.push(processedSubitems);
|
||||
|
||||
current += subitems.length;
|
||||
|
||||
if(current < total) {
|
||||
this.$timeout(() => { decryptNext(); });
|
||||
} else {
|
||||
completion();
|
||||
}
|
||||
}
|
||||
|
||||
decryptNext();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -266,6 +288,12 @@ class SyncManager {
|
||||
this.syncStatus.current = 0;
|
||||
}
|
||||
|
||||
// If items are marked as dirty during a long running sync request, total isn't updated
|
||||
// This happens mostly in the case of large imports and sync conflicts where duplicated items are created
|
||||
if(this.syncStatus.current > this.syncStatus.total) {
|
||||
this.syncStatus.total = this.syncStatus.current;
|
||||
}
|
||||
|
||||
// when doing a sync request that returns items greater than the limit, and thus subsequent syncs are required,
|
||||
// we want to keep track of all retreived items, then save to local storage only once all items have been retrieved,
|
||||
// so that relationships remain intact
|
||||
|
||||
Reference in New Issue
Block a user