Code refactoring (promises for folders management)

This commit is contained in:
RainLoop Team 2015-03-17 18:12:19 +04:00
parent 9bec1d0a8f
commit bab64a7cea
19 changed files with 467 additions and 333 deletions

View file

@ -15,7 +15,7 @@
FolderStore = require('Stores/User/Folder'),
Remote = require('Remote/User/Ajax'),
Promises = require('Promises/User/Ajax'),
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView')
@ -76,21 +76,9 @@
sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
}
FolderStore.foldersCreating(true);
Remote.folderCreate(function (sResult, oData) {
FolderStore.foldersCreating(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('App/User').folders();
}
else
{
FolderStore.folderList.error(
oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) : Translator.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'));
}
}, this.folderName(), sParentFolderName);
require('App/User').foldersPromisesActionHelper(
Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
Enums.Notification.CantCreateFolder);
this.cancelCommand();

View file

@ -212,7 +212,11 @@
this.viewThreads.trigger = ko.observable(false);
this.viewThreadMessages = ko.observableArray([]);
this.viewThreadMessages.hash = '';
this.viewThreadMessages.error = ko.observable('');
this.viewThreadMessages.subscribe(function () {
this.viewThreadMessages.error('');
}, this);
MessageStore.messageLastThreadUidsData.subscribe(function (oData) {
if (oData && oData['Uids'])
@ -320,11 +324,11 @@
self.viewThreadMessages(aList);
}, function (iErrorCode) {
window.alert(Translator.getNotification(iErrorCode));
});
}).fail(function (iErrorCode) {
self.viewThreadMessages([]);
self.viewThreadMessages.error(Translator.getNotification(
iErrorCode, '', Enums.Notification.CantGetMessageList));
}).done();
}
}, function () {