Calendar: Better refresh when toggling integrated apps

This commit is contained in:
nathangray 2021-03-09 10:06:51 -07:00
parent f2cb47105e
commit 2df67647d8
2 changed files with 37 additions and 9 deletions

View File

@ -803,19 +803,31 @@ var CalendarApp = /** @class */ (function (_super) {
}
// Make sure it's an array, not an object
integration_preference = jQuery.extend([], integration_preference);
var callback = function () { };
if (action.checked) {
integration_preference.push(app);
// After the preference change is done, get new info which should now include the app
callback = function () {
this._fetch_data(this.state);
}.bind(this);
}
else {
var index = integration_preference.indexOf(app);
if (index > -1) {
integration_preference.splice(index, 1);
}
// Clear any events from that app
var events = egw.dataKnownUIDs('calendar');
for (var i = 0; i < events.length; i++) {
var event_data = egw.dataGetUIDdata("calendar::" + events[i]).data || { app: "calendar" };
if (event_data && event_data.app === app) {
// Remove entry, then delete it from the cache
egw.dataStoreUID("calendar::" + events[i], null);
egw.dataDeleteUID('calendar::' + events[i]);
}
}
}
egw.set_preference("calendar", "integration_toggle", integration_preference);
// Force redraw to current state with new info, but wait a bit to let preference change get there first
this._clear_cache();
window.setTimeout(function () { this.setState({ state: this.state }); }.bind(this), 500);
egw.set_preference("calendar", "integration_toggle", integration_preference, callback);
};
/**
* Set the app header

View File

@ -799,9 +799,16 @@ class CalendarApp extends EgwApp
// Make sure it's an array, not an object
integration_preference = jQuery.extend([],integration_preference);
let callback = function() {};
if(action.checked)
{
integration_preference.push(app);
// After the preference change is done, get new info which should now include the app
callback = function() {
this._fetch_data(this.state);
}.bind(this);
}
else
{
@ -809,12 +816,21 @@ class CalendarApp extends EgwApp
if (index > -1) {
integration_preference.splice(index, 1);
}
}
egw.set_preference("calendar","integration_toggle",integration_preference);
// Force redraw to current state with new info, but wait a bit to let preference change get there first
this._clear_cache();
window.setTimeout(function() {this.setState({state: this.state})}.bind(this),500);
// Clear any events from that app
let events = egw.dataKnownUIDs('calendar');
for(let i = 0; i < events.length; i++)
{
let event_data = egw.dataGetUIDdata("calendar::" + events[i]).data || {app: "calendar"};
if(event_data && event_data.app === app)
{
// Remove entry, then delete it from the cache
egw.dataStoreUID("calendar::"+events[i], null);
egw.dataDeleteUID('calendar::' + events[i]);
}
}
}
egw.set_preference("calendar","integration_toggle",integration_preference, callback);
}
/**