mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Sortable accounts list
This commit is contained in:
parent
965ea317e4
commit
b563528be7
10 changed files with 150 additions and 28 deletions
44
dev/Stores/User/Account.js
Normal file
44
dev/Stores/User/Account.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Remote = require('Storage/User/Remote')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AccountUserStore()
|
||||
{
|
||||
this.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.collection = ko.observableArray([]);
|
||||
this.collectionEmailNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.collectionEmailNames.skipFirst = true;
|
||||
|
||||
this.collection.subscribe(function (aList) {
|
||||
this.collectionEmailNames(_.compact(_.map(aList, function (oItem) {
|
||||
return oItem ? oItem.email : null;
|
||||
})));
|
||||
}, this);
|
||||
|
||||
this.collectionEmailNames.subscribe(function (aList) {
|
||||
if (this.collectionEmailNames.skipFirst)
|
||||
{
|
||||
this.collectionEmailNames.skipFirst = false;
|
||||
}
|
||||
else if (aList && 1 < aList.length)
|
||||
{
|
||||
Remote.accountSortOrder(null, aList);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
module.exports = new AccountUserStore();
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue