this.isIncompleteChecked = ko.computed(function () { var iM = Data.messageList().length, iC = Data.messageListChecked().length ; return 0 < iM && 0 < iC && iM > iC; }, this);
Data.layout.subscribe(function (nValue) { Data.messageList([]); Remote.saveSettings(null, { 'Layout': nValue }); });
Data.useThreads.subscribe(function (bValue) { Data.messageList([]); Remote.saveSettings(null, { 'UseThreads': bValue ? '1' : '0' }); });
MessageListMailBoxAppView.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction) { var oFolder = null, aMessages = Data.messageList() ; if ('' !== sFolderFullNameRaw) { oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { switch (iSetAction) { case Enums.MessageSetAction.SetSeen: oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { _.each(aMessages, function (oMessage) { oMessage.unseen(false); }); oFolder.messageCountUnread(0); Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); } Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true); break; case Enums.MessageSetAction.UnsetSeen: oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { _.each(aMessages, function (oMessage) { oMessage.unseen(true); }); oFolder.messageCountUnread(oFolder.messageCountAll()); Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); } Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false); break; } require('App/App').reloadFlagsCurrentMessageListAndMessageFromCache(); } } };
this.clearCommand = Utils.createCommand(this, function () { var self = this, oFolderToClear = this.selectedFolder() ; if (oFolderToClear) { Data.message(null); Data.messageList([]); this.clearingProcess(true); oFolderToClear.messageCountAll(0); oFolderToClear.messageCountUnread(0); Cache.setFolderHash(oFolderToClear.fullNameRaw, ''); Remote.folderClear(function (sResult, oData) { self.clearingProcess(false); if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { require('App/App').reloadMessageList(true); self.cancelCommand(); } else { if (oData && oData.ErrorCode) { self.clearingError(Utils.getNotification(oData.ErrorCode)); } else { self.clearingError(Utils.getNotification(Enums.Notification.MailServerError)); } } }, oFolderToClear.fullNameRaw); } }, function () {
'write': function (bValue) { bValue = !!bValue; _.each(Data.messageList(), function (oMessage) { oMessage.checked(bValue); }); }