1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-14 03:15:49 +02:00

Rewrite browser reload to save column notification state in session data

This commit is contained in:
chylex 2017-08-05 18:36:17 +02:00
parent abbdde851e
commit 65b7167b5f
3 changed files with 16 additions and 6 deletions

View File

@ -328,7 +328,7 @@ private void trayIcon_ClickClose(object sender, EventArgs e){
}
private void plugins_Reloaded(object sender, PluginErrorEventArgs e){
browser.GetBrowser().Reload();
ReloadToTweetDeck();
}
private void plugins_PluginChangedState(object sender, PluginChangedStateEventArgs e){
@ -429,7 +429,7 @@ public void UpdateProperties(PropertyBridge.Environment environment){
}
public void ReloadToTweetDeck(){
browser.ExecuteScriptAsync($"gc&&gc();window.location.href='{TwitterUtils.TweetDeckURL}'");
browser.ExecuteScriptAsync($"if(window.TDGF_reload)window.TDGF_reload();else window.location.href='{TwitterUtils.TweetDeckURL}'");
}
// callback handlers

View File

@ -854,8 +854,19 @@
}
//
// Block: Memory cleanup check and execution.
// Block: Custom reload function with memory cleanup.
//
window.TDGF_reload = function(){
let session = TD.storage.feedController.getAll()
.filter(feed => !!feed.getTopSortIndex())
.reduce((obj, feed) => (obj[feed.privateState.key] = feed.getTopSortIndex(), obj), {});
$TD.setSessionData("gc", JSON.stringify(session)).then(() => {
window.gc && window.gc();
window.location.reload();
});
};
window.TDGF_tryRunCleanup = function(){
// all textareas are empty
if ($("textarea").is(function(){
@ -882,8 +893,7 @@
}
// cleanup
window.gc && window.gc();
window.location.reload();
window.TDGF_reload();
return true;
};

View File

@ -98,7 +98,7 @@
//
window.TDPF_requestReload = function(){
if (!isReloading){
window.setTimeout(() => location.reload(), 1);
window.setTimeout(window.TDGF_reload, 1);
isReloading = true;
}
};