1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-14 21:16:58 +02:00

Fix 'Escape' key not clearing notification tweet queue & refactor HideNotification

This commit is contained in:
2017-10-31 11:31:01 +01:00
parent 64977964e8
commit 512b5666ac
6 changed files with 21 additions and 32 deletions

@@ -19,7 +19,7 @@ namespace TweetDuck.Core.Handling {
return true; return true;
case Keys.Escape: case Keys.Escape:
notification.InvokeAsyncSafe(() => notification.HideNotification(true)); notification.InvokeAsyncSafe(notification.HideNotification);
return true; return true;
case Keys.Space: case Keys.Space:

@@ -167,11 +167,8 @@ namespace TweetDuck.Core.Notification{
// notification methods // notification methods
public virtual void HideNotification(bool loadBlank){ public virtual void HideNotification(){
if (loadBlank){ browser.Load("about:blank");
browser.Load("about:blank");
}
Location = ControlExtensions.InvisibleLocation; Location = ControlExtensions.InvisibleLocation;
currentNotification = null; currentNotification = null;
} }

@@ -148,7 +148,7 @@ namespace TweetDuck.Core.Notification{
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){ private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
if (e.CloseReason == CloseReason.UserClosing){ if (e.CloseReason == CloseReason.UserClosing){
HideNotification(true); HideNotification();
e.Cancel = true; e.Cancel = true;
} }
} }
@@ -205,8 +205,8 @@ namespace TweetDuck.Core.Notification{
UpdateTitle(); UpdateTitle();
} }
public override void HideNotification(bool loadBlank){ public override void HideNotification(){
base.HideNotification(loadBlank); base.HideNotification();
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0; progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
timerProgress.Stop(); timerProgress.Stop();

@@ -40,7 +40,6 @@ namespace TweetDuck.Core.Notification {
// //
// FormNotificationTweet // FormNotificationTweet
// //
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormNotificationTweet_FormClosing);
this.ResumeLayout(true); this.ResumeLayout(true);
} }

@@ -26,20 +26,6 @@ namespace TweetDuck.Core.Notification{
} }
} }
private void FormNotificationTweet_FormClosing(object sender, FormClosingEventArgs e){
if (e.CloseReason == CloseReason.UserClosing){
tweetQueue.Clear(); // already canceled
TrimQueue();
}
}
private void TrimQueue(){
if (needsTrim){
tweetQueue.TrimExcess();
needsTrim = false;
}
}
// event handlers // event handlers
private void Config_MuteToggled(object sender, EventArgs e){ private void Config_MuteToggled(object sender, EventArgs e){
@@ -68,11 +54,9 @@ namespace TweetDuck.Core.Notification{
// notification methods // notification methods
public override void ShowNotification(TweetNotification notification){ public override void ShowNotification(TweetNotification notification){
if (IsPaused){ tweetQueue.Enqueue(notification);
tweetQueue.Enqueue(notification);
} if (!IsPaused){
else{
tweetQueue.Enqueue(notification);
UpdateTitle(); UpdateTitle();
if (totalTime == 0){ if (totalTime == 0){
@@ -83,13 +67,22 @@ namespace TweetDuck.Core.Notification{
needsTrim |= tweetQueue.Count >= TrimMinimum; needsTrim |= tweetQueue.Count >= TrimMinimum;
} }
public override void HideNotification(){
base.HideNotification();
tweetQueue.Clear();
if (needsTrim){
tweetQueue.TrimExcess();
needsTrim = false;
}
}
public override void FinishCurrentNotification(){ public override void FinishCurrentNotification(){
if (tweetQueue.Count > 0){ if (tweetQueue.Count > 0){
LoadNextNotification(); LoadNextNotification();
} }
else{ else{
HideNotification(true); HideNotification();
TrimQueue();
} }
} }

@@ -110,7 +110,7 @@ namespace TweetDuck.Core.Other.Settings{
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){ private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
if (Parent == null){ if (Parent == null){
notification.HideNotification(false); notification.HideNotification();
} }
else{ else{
notification.ShowNotificationForSettings(true); notification.ShowNotificationForSettings(true);