update title if flags change
This commit is contained in:
Родитель
0a6ca62403
Коммит
e6217c8e65
|
@ -30,7 +30,7 @@ define(function(require) {
|
|||
var Handlebars = require('handlebars');
|
||||
var Marionette = require('marionette');
|
||||
var OC = require('OC');
|
||||
var AppView = require('views/app');
|
||||
var AppView = require('views/appview');
|
||||
var Cache = require('cache');
|
||||
var Radio = require('radio');
|
||||
var Router = require('router');
|
||||
|
|
|
@ -139,7 +139,7 @@ define(function(require) {
|
|||
Cache.addMessageList(changedAccount, localFolder, cachedList);
|
||||
}
|
||||
|
||||
State.folderView.updateTitle();
|
||||
Radio.ui.trigger('title:update');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -173,18 +173,22 @@ define(function(require) {
|
|||
message.get('flags').set(flag, value);
|
||||
|
||||
// Update folder counter
|
||||
// TODO: drafts folder
|
||||
// TODO: update page title
|
||||
if (flag === 'unseen') {
|
||||
var unseen = Math.max(0, prevUnseen + (value ? 1 : -1));
|
||||
folder.set('unseen', unseen);
|
||||
}
|
||||
|
||||
// Update the folder to reflect the new unread count
|
||||
Radio.ui.trigger('title:update');
|
||||
|
||||
var flaggingMessage = Radio.message.request('flag', account, folder, message, flag, value);
|
||||
$.when(flaggingMessage).fail(function() {
|
||||
Radio.ui.trigger('error:show', t('mail', 'Message flag could not be set.'));
|
||||
|
||||
// Restore previous state
|
||||
message.get('flags').set(flag, !value);
|
||||
folder.set('unseen', prevUnseen);
|
||||
Radio.ui.trigger('title:update');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @copyright Christoph Wurst 2015, 2016
|
||||
* @copyright Christoph Wurst 2015
|
||||
*/
|
||||
|
||||
define(function(require) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global oc_defaults */
|
||||
|
||||
/**
|
||||
* ownCloud - Mail
|
||||
*
|
||||
|
@ -51,6 +53,7 @@ define(function(require) {
|
|||
this.listenTo(Radio.ui, 'setup:show', this.showSetup);
|
||||
this.listenTo(Radio.ui, 'foldercontent:show', this.showFolderContent);
|
||||
this.listenTo(Radio.ui, 'content:loading', this.showContentLoading);
|
||||
this.listenTo(Radio.ui, 'title:update', this.updateTitle);
|
||||
|
||||
// Hide notification favicon when switching back from
|
||||
// another browser tab
|
||||
|
@ -168,7 +171,34 @@ define(function(require) {
|
|||
this.activeContent = ContentType.LOADING;
|
||||
this.content.show(new LoadingView());
|
||||
}
|
||||
}
|
||||
},
|
||||
updateTitle: function() {
|
||||
var activeEmail = '';
|
||||
if (require('state').currentAccount.get('accountId') !== -1) {
|
||||
var activeAccount = require('state').currentAccount;
|
||||
activeEmail = ' - ' + activeAccount.get('email');
|
||||
}
|
||||
var activeFolder = require('state').currentFolder;
|
||||
var name = activeFolder.name || activeFolder.get('name');
|
||||
var count = 0;
|
||||
// TODO: use specialUse instead, otherwise this won't work with localized drafts folders
|
||||
if (name === 'Drafts') {
|
||||
count = activeFolder.total || activeFolder.get('total');
|
||||
} else {
|
||||
count = activeFolder.unseen || activeFolder.get('unseen');
|
||||
}
|
||||
if (count > 0) {
|
||||
window.document.title = name + ' (' + count + ')' +
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
activeEmail + ' - Mail - ' + oc_defaults.title;
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
} else {
|
||||
window.document.title = name + activeEmail +
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
' - Mail - ' + oc_defaults.title;
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return AppView;
|
|
@ -98,7 +98,7 @@ define(function(require) {
|
|||
}
|
||||
|
||||
require('state').currentMessageId = messageId;
|
||||
require('state').folderView.updateTitle();
|
||||
Radio.ui.trigger('title:update');
|
||||
|
||||
},
|
||||
selectNextMessage: function() {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* global oc_defaults */
|
||||
|
||||
/**
|
||||
* ownCloud - Mail
|
||||
*
|
||||
|
@ -35,35 +33,6 @@ define(function(require) {
|
|||
this.listenTo(Radio.ui, 'folder:changed', this.onFolderChanged);
|
||||
this.listenTo(Radio.folder, 'setactive', this.setFolderActive);
|
||||
},
|
||||
/**
|
||||
* @returns {undefined}
|
||||
*/
|
||||
updateTitle: function() {
|
||||
var activeEmail = '';
|
||||
if (require('state').currentAccount.get('accountId') !== -1) {
|
||||
var activeAccount = require('state').currentAccount;
|
||||
activeEmail = ' - ' + activeAccount.get('email');
|
||||
}
|
||||
var activeFolder = require('state').currentFolder;
|
||||
var name = activeFolder.name || activeFolder.get('name');
|
||||
var count = 0;
|
||||
if (name === 'Drafts') {
|
||||
count = activeFolder.total || activeFolder.get('total');
|
||||
} else {
|
||||
count = activeFolder.unseen || activeFolder.get('unseen');
|
||||
}
|
||||
if (count > 0) {
|
||||
window.document.title = name + ' (' + count + ')' +
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
activeEmail + ' - Mail - ' + oc_defaults.title;
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
} else {
|
||||
window.document.title = name + activeEmail +
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
' - Mail - ' + oc_defaults.title;
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {Account} account
|
||||
* @param {Folder} folder
|
||||
|
|
Загрузка…
Ссылка в новой задаче