mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-03 23:34:09 +02:00
Remove broken feature that showed missed notifications after reload
This commit is contained in:
parent
a310c5bcc1
commit
fa8b4e1e7f
@ -1,13 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Windows.Forms;
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using CefSharp;
|
|
||||||
using TweetDuck.Core.Controls;
|
using TweetDuck.Core.Controls;
|
||||||
using TweetDuck.Core.Management;
|
using TweetDuck.Core.Management;
|
||||||
using TweetDuck.Core.Notification;
|
using TweetDuck.Core.Notification;
|
||||||
using TweetDuck.Core.Other;
|
using TweetDuck.Core.Other;
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
using TweetDuck.Resources;
|
|
||||||
|
|
||||||
namespace TweetDuck.Core.Bridge{
|
namespace TweetDuck.Core.Bridge{
|
||||||
class TweetDeckBridge{
|
class TweetDeckBridge{
|
||||||
@ -15,25 +11,10 @@ class TweetDeckBridge{
|
|||||||
public static string NotificationHeadLayout { get; private set; }
|
public static string NotificationHeadLayout { get; private set; }
|
||||||
public static readonly ContextInfo ContextInfo = new ContextInfo();
|
public static readonly ContextInfo ContextInfo = new ContextInfo();
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> SessionData = new Dictionary<string, string>(2);
|
|
||||||
|
|
||||||
public static void ResetStaticProperties(){
|
public static void ResetStaticProperties(){
|
||||||
FontSize = NotificationHeadLayout = null;
|
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 FormBrowser form;
|
||||||
private readonly FormNotificationMain notification;
|
private readonly FormNotificationMain notification;
|
||||||
|
|
||||||
@ -79,12 +60,6 @@ public void SetRightClickedChirp(string tweetUrl, string quoteUrl, string chirpA
|
|||||||
public void DisplayTooltip(string text){
|
public void DisplayTooltip(string text){
|
||||||
form.InvokeAsyncSafe(() => form.DisplayTooltip(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
|
// Notification only
|
||||||
|
@ -130,7 +130,6 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
|||||||
if (frame.IsMain){
|
if (frame.IsMain){
|
||||||
if (TwitterUtils.IsTweetDeckWebsite(frame)){
|
if (TwitterUtils.IsTweetDeckWebsite(frame)){
|
||||||
UpdateProperties();
|
UpdateProperties();
|
||||||
TweetDeckBridge.RestoreSessionData(frame);
|
|
||||||
ScriptLoader.ExecuteFile(frame, "code.js", browser);
|
ScriptLoader.ExecuteFile(frame, "code.js", browser);
|
||||||
|
|
||||||
InjectBrowserCSS();
|
InjectBrowserCSS();
|
||||||
|
@ -1587,79 +1587,12 @@
|
|||||||
// Block: Custom reload function with memory cleanup.
|
// Block: Custom reload function with memory cleanup.
|
||||||
//
|
//
|
||||||
window.TDGF_reload = function(){
|
window.TDGF_reload = function(){
|
||||||
try{
|
window.gc && window.gc();
|
||||||
let session = TD.storage.feedController.getAll()
|
window.location.reload();
|
||||||
.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.TDGF_reload = function(){}; // redefine to prevent reloading multiple times
|
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.
|
// Block: Disable default TweetDeck update notification.
|
||||||
//
|
//
|
||||||
@ -1694,8 +1627,6 @@
|
|||||||
onAppReady.forEach(func => execSafe(func));
|
onAppReady.forEach(func => execSafe(func));
|
||||||
onAppReady = null;
|
onAppReady = null;
|
||||||
|
|
||||||
delete window.TD_SESSION;
|
|
||||||
|
|
||||||
if (window.TD_PLUGINS){
|
if (window.TD_PLUGINS){
|
||||||
window.TD_PLUGINS.onReady();
|
window.TD_PLUGINS.onReady();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user