diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 4c111f1b..d71ebc94 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -1,13 +1,9 @@ -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using CefSharp; +using System.Windows.Forms; using TweetDuck.Core.Controls; using TweetDuck.Core.Management; using TweetDuck.Core.Notification; using TweetDuck.Core.Other; using TweetDuck.Core.Utils; -using TweetDuck.Resources; namespace TweetDuck.Core.Bridge{ class TweetDeckBridge{ @@ -15,25 +11,10 @@ class TweetDeckBridge{ public static string NotificationHeadLayout { get; private set; } public static readonly ContextInfo ContextInfo = new ContextInfo(); - private static readonly Dictionary<string, string> SessionData = new Dictionary<string, string>(2); - public static void ResetStaticProperties(){ FontSize = NotificationHeadLayout = null; } - public static void RestoreSessionData(IFrame frame){ - if (SessionData.Count > 0){ - StringBuilder build = new StringBuilder(22).Append("window.TD_SESSION={"); - - foreach(KeyValuePair<string, string> kvp in SessionData){ - build.Append(kvp.Key).Append(":'").Append(kvp.Value.Replace("'", "\\'")).Append("',"); - } - - ScriptLoader.ExecuteScript(frame, build.Append("}").ToString(), "gen:session"); - SessionData.Clear(); - } - } - private readonly FormBrowser form; private readonly FormNotificationMain notification; @@ -79,12 +60,6 @@ public void SetRightClickedChirp(string tweetUrl, string quoteUrl, string chirpA public void DisplayTooltip(string text){ form.InvokeAsyncSafe(() => form.DisplayTooltip(text)); } - - public void SetSessionData(string key, string value){ - form.InvokeSafe(() => { // do not use InvokeAsyncSafe, return only after invocation - SessionData.Add(key, value); - }); - } } // Notification only diff --git a/Core/TweetDeckBrowser.cs b/Core/TweetDeckBrowser.cs index c176aaad..c024d96a 100644 --- a/Core/TweetDeckBrowser.cs +++ b/Core/TweetDeckBrowser.cs @@ -130,7 +130,6 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ if (frame.IsMain){ if (TwitterUtils.IsTweetDeckWebsite(frame)){ UpdateProperties(); - TweetDeckBridge.RestoreSessionData(frame); ScriptLoader.ExecuteFile(frame, "code.js", browser); InjectBrowserCSS(); diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 1c46023e..94d09729 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -1587,79 +1587,12 @@ // Block: Custom reload function with memory cleanup. // window.TDGF_reload = function(){ - try{ - 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(); - }); - }catch(err){ - $TD.crashDebug("Error saving session during a reload"); - window.location.reload(); - } + window.gc && window.gc(); + window.location.reload(); window.TDGF_reload = function(){}; // redefine to prevent reloading multiple times }; - if (window.TD_SESSION && window.TD_SESSION.gc){ - let state; - - try{ - state = JSON.parse(window.TD_SESSION.gc); - }catch(err){ - $TD.crashDebug("Invalid session gc data: "+window.TD_SESSION.gc); - state = {}; - } - - const showMissedNotifications = function(){ - let tweets = []; - let columns = {}; - - let tmp = new TD.services.ChirpBase; - - for(let column of Object.values(TD.controller.columnManager.getAll())){ - for(let feed of column.getFeeds()){ - if (feed.privateState.key in state){ - tmp.sortIndex = state[feed.privateState.key]; - - for(let tweet of [].concat.apply([], column.updateArray.map(function(chirp){ - return chirp.getUnreadChirps(tmp); - }))){ - tweets.push(tweet); - columns[tweet.id] = column; - } - } - } - } - - tweets.sort(TD.util.chirpReverseColumnSort); - - for(let tweet of tweets){ - onNewTweet(columns[tweet.id], tweet); - } - }; - - execSafe(function showMissedNotifications(){ - throw 1 if !ensurePropertyExists(TD, "controller", "columnManager", "getAll"); - - $(document).one("dataColumnsLoaded", function(){ - let columns = Object.values(TD.controller.columnManager.getAll()); - let remaining = columns.length; - - for(let column of columns){ - column.ui.getChirpContainer().one("dataColumnFeedUpdated", () => { - if (--remaining === 0){ - setTimeout(showMissedNotifications, 1); - } - }); - } - }); - }); - } - // // Block: Disable default TweetDeck update notification. // @@ -1694,8 +1627,6 @@ onAppReady.forEach(func => execSafe(func)); onAppReady = null; - delete window.TD_SESSION; - if (window.TD_PLUGINS){ window.TD_PLUGINS.onReady(); }