Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Lindner <mail@steffen-lindner.de>2016-05-30 20:35:59 +0300
committerSteffen Lindner <mail@steffen-lindner.de>2016-05-30 20:35:59 +0300
commitbec16874180ac8ee028da3844a2954bbe44c2cf1 (patch)
tree86fb216044d0ac67bb897dd9183ac269fb37fe4a
parent1f8f38aa1a5802604014f1bf0cdcb5e7b63a5220 (diff)
parent2c03c1526a1f961050e2f08ef4a2c7e45bd3f44c (diff)
Merge pull request #1505 from owncloud/traverse-folders-correctlyv0.5.1
traverse folders correctly when searching by folder id
-rw-r--r--js/models/account.js35
-rw-r--r--js/routecontroller.js4
-rw-r--r--js/views/composer.js4
3 files changed, 40 insertions, 3 deletions
diff --git a/js/models/account.js b/js/models/account.js
index dc5f4ead4..a72b8b7ec 100644
--- a/js/models/account.js
+++ b/js/models/account.js
@@ -27,6 +27,41 @@ define(function(require) {
initialize: function() {
this.set('folders', new FolderCollection(this.get('folders')));
},
+ _getFolderByIdRecursively: function(folder, folderId) {
+ if (!folder) {
+ return null;
+ }
+
+ if (folder.get('id') === folderId) {
+ return folder;
+ }
+
+ var subFolders = folder.get('folders');
+ if (!subFolders) {
+ return null;
+ }
+ for (var i = 0; i < subFolders.length; i++) {
+ var subFolder = this._getFolderByIdRecursively(subFolders.at(i), folderId);
+ if (subFolder) {
+ return subFolder;
+ }
+ }
+
+ return null;
+ },
+ getFolderById: function(folderId) {
+ var folders = this.get('folders');
+ if (!folders) {
+ return null;
+ }
+ for (var i = 0; i < folders.length; i++) {
+ var result = this._getFolderByIdRecursively(folders.at(i), folderId);
+ if (result) {
+ return result;
+ }
+ }
+ return null;
+ },
toJSON: function() {
var data = Backbone.Model.prototype.toJSON.call(this);
if (data.folders && data.folders.toJSON) {
diff --git a/js/routecontroller.js b/js/routecontroller.js
index 9d6acd927..48019e67f 100644
--- a/js/routecontroller.js
+++ b/js/routecontroller.js
@@ -102,13 +102,15 @@ define(function(require) {
var account = this.accounts.get(accountId);
if (_.isUndefined(account)) {
// Unknown account id -> redirect
+ Radio.ui.trigger('error:show', t('mail', 'Invalid account'));
_this.default();
return;
}
- var folder = account.get('folders').get(folderId);
+ var folder = account.getFolderById(folderId);
if (_.isUndefined(folder)) {
folder = account.get('folders').at(0);
+ Radio.ui.trigger('error:show', t('mail', 'Invalid folder'));
this._navigate('accounts/' + accountId + '/folders/' + folder.get('id'));
}
FolderController.showFolder(account, folder, noSelect);
diff --git a/js/views/composer.js b/js/views/composer.js
index e57c05d77..63dac0cf8 100644
--- a/js/views/composer.js
+++ b/js/views/composer.js
@@ -306,7 +306,7 @@ define(function(require) {
if (this.isReply()) {
options.messageId = this.messageId;
- options.folder = this.account.get('folders').get(this.folderId);
+ options.folder = this.account.getFolderById(this.folderId);
}
var sendingMessage = Radio.message.request('send', this.account, this.getMessage(), options);
@@ -376,7 +376,7 @@ define(function(require) {
// send the mail
var _this = this;
var savingDraft = Radio.message.request('draft', this.account, this.getMessage(), {
- folder: this.account.get('folders').get(this.folderId),
+ folder: this.account.getFolderById(this.folderId),
messageId: this.messageId,
draftUID: this.draftUID
});