mail/js/service/folderservice.js

54 строки
997 B
JavaScript
Исходник Обычный вид История

/**
* Mail
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
2016-03-11 00:03:01 +03:00
* @copyright Christoph Wurst 2015, 2016
*/
define(function(require) {
'use strict';
var $ = require('jquery');
var OC = require('OC');
2016-03-11 00:03:01 +03:00
/**
* @param {Account} account
* @returns {Promise}
*/
2016-02-22 13:57:39 +03:00
function getFolderEntities(account) {
var defer = $.Deferred();
2016-02-22 13:57:39 +03:00
var url = OC.generateUrl('apps/mail/accounts/{id}/folders',
{
2016-02-22 13:57:39 +03:00
id: account.get('accountId')
});
var promise = $.get(url);
promise.done(function(data) {
2016-02-22 13:57:39 +03:00
for (var prop in data) {
if (prop === 'folders') {
2016-09-21 00:33:10 +03:00
account.folders.reset();
account.addFolder(data.folders);
2016-02-22 13:57:39 +03:00
} else {
account.set(prop, data[prop]);
}
}
2016-09-21 00:33:10 +03:00
defer.resolve(account.folders);
});
promise.fail(function() {
defer.reject();
});
return defer.promise();
}
return {
getFolderEntities: getFolderEntities
};
});