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

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

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

View File

@ -19,7 +19,7 @@ bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser
return true;
case Keys.Escape:
notification.InvokeAsyncSafe(() => notification.HideNotification(true));
notification.InvokeAsyncSafe(notification.HideNotification);
return true;
case Keys.Space:

View File

@ -167,11 +167,8 @@ private void Browser_IsBrowserInitializedChanged(object sender, IsBrowserInitial
// notification methods
public virtual void HideNotification(bool loadBlank){
if (loadBlank){
browser.Load("about:blank");
}
public virtual void HideNotification(){
browser.Load("about:blank");
Location = ControlExtensions.InvisibleLocation;
currentNotification = null;
}

View File

@ -148,7 +148,7 @@ private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
if (e.CloseReason == CloseReason.UserClosing){
HideNotification(true);
HideNotification();
e.Cancel = true;
}
}
@ -205,8 +205,8 @@ public void ShowNotificationForSettings(bool reset){
UpdateTitle();
}
public override void HideNotification(bool loadBlank){
base.HideNotification(loadBlank);
public override void HideNotification(){
base.HideNotification();
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
timerProgress.Stop();

View File

@ -40,7 +40,6 @@ private void InitializeComponent() {
//
// FormNotificationTweet
//
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormNotificationTweet_FormClosing);
this.ResumeLayout(true);
}

View File

@ -26,20 +26,6 @@ public FormNotificationTweet(FormBrowser owner, PluginManager pluginManager) : b
}
}
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
private void Config_MuteToggled(object sender, EventArgs e){
@ -68,11 +54,9 @@ private void timerIdlePauseCheck_Tick(object sender, EventArgs e){
// notification methods
public override void ShowNotification(TweetNotification notification){
if (IsPaused){
tweetQueue.Enqueue(notification);
}
else{
tweetQueue.Enqueue(notification);
tweetQueue.Enqueue(notification);
if (!IsPaused){
UpdateTitle();
if (totalTime == 0){
@ -83,13 +67,22 @@ public override void ShowNotification(TweetNotification notification){
needsTrim |= tweetQueue.Count >= TrimMinimum;
}
public override void HideNotification(){
base.HideNotification();
tweetQueue.Clear();
if (needsTrim){
tweetQueue.TrimExcess();
needsTrim = false;
}
}
public override void FinishCurrentNotification(){
if (tweetQueue.Count > 0){
LoadNextNotification();
}
else{
HideNotification(true);
TrimQueue();
HideNotification();
}
}

View File

@ -110,7 +110,7 @@ public override void OnReady(){
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
if (Parent == null){
notification.HideNotification(false);
notification.HideNotification();
}
else{
notification.ShowNotificationForSettings(true);