Refresh the entire tasks list/calendar on every 10th request to sync deleted items (#2369)
This commit is contained in:
parent
310e25d0d1
commit
9c248384dd
3 changed files with 33 additions and 15 deletions
|
@ -924,19 +924,28 @@ class calendar extends rcube_plugin
|
|||
*/
|
||||
public function refresh($attr)
|
||||
{
|
||||
foreach ($this->driver->list_calendars(true) as $cal) {
|
||||
$events = $this->driver->load_events(
|
||||
get_input_value('start', RCUBE_INPUT_GET),
|
||||
get_input_value('end', RCUBE_INPUT_GET),
|
||||
get_input_value('q', RCUBE_INPUT_GET),
|
||||
$cal['id'],
|
||||
1,
|
||||
$attr['last']
|
||||
);
|
||||
// refresh the entire calendar every 10th time to also sync deleted events
|
||||
$refetch = rand(0,10) == 10;
|
||||
|
||||
foreach ($events as $event) {
|
||||
$args = array('source' => $cal['id'], 'update' => $this->_client_event($event));
|
||||
$this->rc->output->command('plugin.refresh_calendar', $args);
|
||||
foreach ($this->driver->list_calendars(true) as $cal) {
|
||||
if ($refetch) {
|
||||
$this->rc->output->command('plugin.refresh_calendar',
|
||||
array('source' => $cal['id'], 'refetch' => true));
|
||||
}
|
||||
else {
|
||||
$events = $this->driver->load_events(
|
||||
get_input_value('start', RCUBE_INPUT_GET),
|
||||
get_input_value('end', RCUBE_INPUT_GET),
|
||||
get_input_value('q', RCUBE_INPUT_GET),
|
||||
$cal['id'],
|
||||
1,
|
||||
$attr['last']
|
||||
);
|
||||
|
||||
foreach ($events as $event) {
|
||||
$this->rc->output->command('plugin.refresh_calendar',
|
||||
array('source' => $cal['id'], 'update' => $this->_client_event($event)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,9 +135,12 @@ function rcube_tasklist_ui(settings)
|
|||
rcmail.addEventListener('plugin.insert_tasklist', insert_list);
|
||||
rcmail.addEventListener('plugin.update_tasklist', update_list);
|
||||
rcmail.addEventListener('plugin.destroy_tasklist', destroy_list);
|
||||
rcmail.addEventListener('plugin.reload_data', function(){ list_tasks(null); });
|
||||
rcmail.addEventListener('plugin.unlock_saving', unlock_saving);
|
||||
rcmail.addEventListener('requestrefresh', before_refresh);
|
||||
rcmail.addEventListener('plugin.reload_data', function(){
|
||||
list_tasks(null, true);
|
||||
setTimeout(fetch_counts, 200);
|
||||
});
|
||||
|
||||
// start loading tasks
|
||||
fetch_counts();
|
||||
|
@ -400,7 +403,7 @@ function rcube_tasklist_ui(settings)
|
|||
/**
|
||||
* List tasks matching the given selector
|
||||
*/
|
||||
function list_tasks(sel)
|
||||
function list_tasks(sel, force)
|
||||
{
|
||||
if (rcmail.busy)
|
||||
return;
|
||||
|
@ -412,7 +415,7 @@ function rcube_tasklist_ui(settings)
|
|||
|
||||
var active = active_lists(),
|
||||
basefilter = filtermask == FILTER_MASK_COMPLETE ? FILTER_MASK_COMPLETE : FILTER_MASK_ALL,
|
||||
reload = active.join(',') != loadstate.lists || basefilter != loadstate.filter || loadstate.search != search_query;
|
||||
reload = force || active.join(',') != loadstate.lists || basefilter != loadstate.filter || loadstate.search != search_query;
|
||||
|
||||
if (active.length && reload) {
|
||||
ui_loading = rcmail.set_busy(true, 'loading');
|
||||
|
|
|
@ -742,6 +742,12 @@ class tasklist extends rcube_plugin
|
|||
*/
|
||||
public function refresh($attr)
|
||||
{
|
||||
// refresh the entire list every 10th time to also sync deleted items
|
||||
if (rand(0,10) == 10) {
|
||||
$this->rc->output->command('plugin.reload_data');
|
||||
return;
|
||||
}
|
||||
|
||||
$filter = array(
|
||||
'since' => $attr['last'],
|
||||
'search' => get_input_value('q', RCUBE_INPUT_GPC),
|
||||
|
|
Loading…
Add table
Reference in a new issue