mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-03-20 03:38:33 +08:00
Automatic contacts syncronization (every 10m)
This commit is contained in:
parent
d476a6a3ac
commit
0ce7b03fd0
11 changed files with 336 additions and 258 deletions
|
@ -42,6 +42,12 @@ function RainLoopApp()
|
|||
RL.pub('interval.10m');
|
||||
}, 60000 * 10);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setInterval(function () {
|
||||
RL.pub('interval.10m-after5m');
|
||||
}, 60000 * 10);
|
||||
}, 60000 * 5);
|
||||
|
||||
$.wakeUp(function () {
|
||||
RL.remote().jsVersion(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult && oData && !oData.Result)
|
||||
|
@ -172,6 +178,41 @@ RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList)
|
|||
RL.reloadMessageList(bEmptyList);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fResultFunc
|
||||
* @param {boolean=} bForce = false
|
||||
* @returns {boolean}
|
||||
*/
|
||||
RainLoopApp.prototype.contactsSync = function (fResultFunc, bForce)
|
||||
{
|
||||
var oContacts = RL.data().contacts;
|
||||
if (oContacts.importing() || oContacts.syncing() || !RL.data().enableContactsSync() || !RL.data().allowContactsSync())
|
||||
{
|
||||
oContacts.skipNextSync = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oContacts.skipNextSync && !bForce)
|
||||
{
|
||||
oContacts.skipNextSync = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
oContacts.syncing(true);
|
||||
|
||||
RL.remote().contactsSync(function (sResult, oData) {
|
||||
|
||||
oContacts.syncing(false);
|
||||
|
||||
if (fResultFunc)
|
||||
{
|
||||
fResultFunc(sResult, oData);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
RainLoopApp.prototype.messagesMoveTrigger = function ()
|
||||
{
|
||||
var self = this;
|
||||
|
@ -1110,6 +1151,14 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.folders();
|
||||
});
|
||||
|
||||
RL.sub('interval.10m-after5m', function () {
|
||||
RL.contactsSync();
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
RL.contactsSync();
|
||||
}, 5000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.folderInformationMultiply(true);
|
||||
}, 500);
|
||||
|
|
|
@ -82,6 +82,13 @@ function WebMailDataStorage()
|
|||
this.identities = ko.observableArray([]);
|
||||
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
// contacts
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.skipNextSync = false;
|
||||
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
|
|
|
@ -17,14 +17,12 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
;
|
||||
|
||||
this.allowContactsSync = RL.data().allowContactsSync;
|
||||
this.enableContactsSync = RL.data().enableContactsSync;
|
||||
|
||||
this.search = ko.observable('');
|
||||
this.contactsCount = ko.observable(0);
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts = RL.data().contacts;
|
||||
|
||||
this.currentContact = ko.observable(null);
|
||||
|
||||
|
@ -258,20 +256,8 @@ function PopupsContactsViewModel()
|
|||
|
||||
this.syncCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (this.contacts.syncing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
this.contacts.syncing(true);
|
||||
|
||||
|
||||
RL.remote().contactsSync(function (sResult, oData) {
|
||||
|
||||
self.contacts.syncing(false);
|
||||
|
||||
RL.contactsSync(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
window.alert(Utils.getNotification(
|
||||
|
@ -279,8 +265,9 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
|
||||
self.reloadContactList(true);
|
||||
}, true);
|
||||
|
||||
});
|
||||
this.contacts.skipNextSync = true;
|
||||
|
||||
}, function () {
|
||||
return !this.contacts.syncing() && !this.contacts.importing();
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
<ul class="dropdown-menu g-ui-menu" role="menu">
|
||||
<li class="e-item">
|
||||
<a class="e-link" data-bind="initDom: importUploaderButton">
|
||||
<i class="icon-list-add"></i>
|
||||
<i data-bind="css: {'icon-list-add': !contacts.importing(), 'icon-spinner animated': contacts.importing}"></i>
|
||||
|
||||
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_IMPORT"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="e-item" data-bind="visible: enableContactsSync">
|
||||
<li class="e-item" data-bind="visible: enableContactsSync() && allowContactsSync()">
|
||||
<a class="e-link" data-bind="command: syncCommand">
|
||||
<i class="icon-sync"></i>
|
||||
<i data-bind="css: {'icon-sync': !contacts.syncing(), 'icon-spinner animated': contacts.syncing}"></i>
|
||||
|
||||
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_SYNC"></span>
|
||||
</a>
|
||||
|
|
|
@ -27,20 +27,12 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="control-group">
|
||||
<label class="control-label">
|
||||
<span class="i18n" data-i18n-text="SETTINGS_CONTACTS/LABEL_CONTACTS_SYNC_SERVER"></span>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" data-bind="" />
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
<span class="i18n" data-i18n-text="SETTINGS_CONTACTS/LABEL_CONTACTS_SYNC_AB_URL"></span>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input class="input-xxlarge" type="text" data-bind="value: contactsSyncUrl" />
|
||||
<input class="input-xxlarge" type="text" data-bind="value: contactsSyncUrl" placeholder="https://" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
|
6
rainloop/v/0.0.0/static/js/admin.min.js
vendored
6
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -9653,14 +9653,12 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
;
|
||||
|
||||
this.allowContactsSync = RL.data().allowContactsSync;
|
||||
this.enableContactsSync = RL.data().enableContactsSync;
|
||||
|
||||
this.search = ko.observable('');
|
||||
this.contactsCount = ko.observable(0);
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts = RL.data().contacts;
|
||||
|
||||
this.currentContact = ko.observable(null);
|
||||
|
||||
|
@ -9894,20 +9892,8 @@ function PopupsContactsViewModel()
|
|||
|
||||
this.syncCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (this.contacts.syncing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
this.contacts.syncing(true);
|
||||
|
||||
|
||||
RL.remote().contactsSync(function (sResult, oData) {
|
||||
|
||||
self.contacts.syncing(false);
|
||||
|
||||
RL.contactsSync(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
window.alert(Utils.getNotification(
|
||||
|
@ -9915,8 +9901,9 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
|
||||
self.reloadContactList(true);
|
||||
}, true);
|
||||
|
||||
});
|
||||
this.contacts.skipNextSync = true;
|
||||
|
||||
}, function () {
|
||||
return !this.contacts.syncing() && !this.contacts.importing();
|
||||
|
@ -15142,6 +15129,13 @@ function WebMailDataStorage()
|
|||
this.identities = ko.observableArray([]);
|
||||
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
// contacts
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.skipNextSync = false;
|
||||
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
|
@ -18535,6 +18529,12 @@ function RainLoopApp()
|
|||
RL.pub('interval.10m');
|
||||
}, 60000 * 10);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setInterval(function () {
|
||||
RL.pub('interval.10m-after5m');
|
||||
}, 60000 * 10);
|
||||
}, 60000 * 5);
|
||||
|
||||
$.wakeUp(function () {
|
||||
RL.remote().jsVersion(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult && oData && !oData.Result)
|
||||
|
@ -18665,6 +18665,41 @@ RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList)
|
|||
RL.reloadMessageList(bEmptyList);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fResultFunc
|
||||
* @param {boolean=} bForce = false
|
||||
* @returns {boolean}
|
||||
*/
|
||||
RainLoopApp.prototype.contactsSync = function (fResultFunc, bForce)
|
||||
{
|
||||
var oContacts = RL.data().contacts;
|
||||
if (oContacts.importing() || oContacts.syncing() || !RL.data().enableContactsSync() || !RL.data().allowContactsSync())
|
||||
{
|
||||
oContacts.skipNextSync = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oContacts.skipNextSync && !bForce)
|
||||
{
|
||||
oContacts.skipNextSync = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
oContacts.syncing(true);
|
||||
|
||||
RL.remote().contactsSync(function (sResult, oData) {
|
||||
|
||||
oContacts.syncing(false);
|
||||
|
||||
if (fResultFunc)
|
||||
{
|
||||
fResultFunc(sResult, oData);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
RainLoopApp.prototype.messagesMoveTrigger = function ()
|
||||
{
|
||||
var self = this;
|
||||
|
@ -19603,6 +19638,14 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.folders();
|
||||
});
|
||||
|
||||
RL.sub('interval.10m-after5m', function () {
|
||||
RL.contactsSync();
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
RL.contactsSync();
|
||||
}, 5000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.folderInformationMultiply(true);
|
||||
}, 500);
|
||||
|
|
16
rainloop/v/0.0.0/static/js/app.min.js
vendored
16
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue