1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-04 17:34:07 +02:00

Refactor FormNotificationBase to store TweetNotification instead of copying data

This commit is contained in:
chylex 2017-08-27 13:40:49 +02:00
parent 380e580d65
commit 588bb9a093

View File

@ -79,17 +79,15 @@ public bool CanResizeWindow{
private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification(); private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification();
private readonly float dpiScale; private readonly float dpiScale;
private string currentColumnKey; private TweetNotification currentNotification;
private string currentChirpId;
private string currentColumnTitle;
private int pauseCounter; private int pauseCounter;
public string CurrentTweetUrl => currentNotification?.TweetUrl;
public string CurrentQuoteUrl => currentNotification?.QuoteUrl;
public bool IsPaused => pauseCounter > 0; public bool IsPaused => pauseCounter > 0;
public bool FreezeTimer { get; set; } public bool FreezeTimer { get; set; }
public bool ContextMenuOpen { get; set; } public bool ContextMenuOpen { get; set; }
public string CurrentTweetUrl { get; private set; }
public string CurrentQuoteUrl { get; private set; }
public event EventHandler Initialized; public event EventHandler Initialized;
@ -160,7 +158,7 @@ public virtual void HideNotification(bool loadBlank){
} }
Location = ControlExtensions.InvisibleLocation; Location = ControlExtensions.InvisibleLocation;
currentColumnTitle = null; currentNotification = null;
} }
public virtual void FinishCurrentNotification(){} public virtual void FinishCurrentNotification(){}
@ -183,13 +181,7 @@ protected virtual string GetTweetHTML(TweetNotification tweet){
} }
protected virtual void LoadTweet(TweetNotification tweet){ protected virtual void LoadTweet(TweetNotification tweet){
CurrentTweetUrl = tweet.TweetUrl; currentNotification = tweet;
CurrentQuoteUrl = tweet.QuoteUrl;
currentColumnKey = tweet.ColumnKey;
currentChirpId = tweet.ChirpId;
currentColumnTitle = tweet.ColumnTitle;
resourceHandler.SetHTML(GetTweetHTML(tweet)); resourceHandler.SetHTML(GetTweetHTML(tweet));
browser.Load(TwitterUtils.TweetDeckURL); browser.Load(TwitterUtils.TweetDeckURL);
} }
@ -203,11 +195,12 @@ protected virtual void OnNotificationReady(){
} }
protected virtual void UpdateTitle(){ protected virtual void UpdateTitle(){
Text = string.IsNullOrEmpty(currentColumnTitle) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+currentColumnTitle; string title = currentNotification?.ColumnTitle;
Text = string.IsNullOrEmpty(title) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+title;
} }
public void ShowTweetDetail(){ public void ShowTweetDetail(){
owner.ShowTweetDetail(currentColumnKey, currentChirpId); owner.ShowTweetDetail(currentNotification.ColumnKey, currentNotification.ChirpId);
} }
public void MoveToVisibleLocation(){ public void MoveToVisibleLocation(){