Skip to content

Commit

Permalink
Fix non-persistent status messages being shown forever
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Dec 9, 2024
1 parent 728d826 commit 722bc3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
2 changes: 0 additions & 2 deletions YAMDCC.ConfigEditor/Dialogs/VersionDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Drawing;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;

namespace YAMDCC.ConfigEditor.Dialogs
Expand Down
50 changes: 24 additions & 26 deletions YAMDCC.ConfigEditor/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public MainWindow()

tmrStatusReset = new()
{
Interval = 10000,
Interval = 5000,
};
tmrStatusReset.Tick += tmrStatusReset_Tick;

Expand Down Expand Up @@ -719,9 +719,7 @@ private void tmrPoll_Tick(object sender, EventArgs e)

private void tmrStatusReset_Tick(object sender, EventArgs e)
{
AppStatus.Code = StatusCode.None;
AppStatus.RepeatCount = 0;
lblStatus.Invoke(() => lblStatus.Text = "Ready");
UpdateStatus(StatusCode.None);
tmrStatusReset.Stop();
}

Expand Down Expand Up @@ -1064,63 +1062,63 @@ private void DisableAll()

private void UpdateStatus(StatusCode status, int data = 0)
{
if (AppStatus.Code == status)
lblStatus.Invoke(() =>
{
AppStatus.RepeatCount++;
}
else
{
AppStatus.Code = status;
AppStatus.RepeatCount = 0;
}
if (AppStatus.Code == status)
{
AppStatus.RepeatCount++;
}
else
{
AppStatus.Code = status;
AppStatus.RepeatCount = 0;
}

// set status text
if (AppStatus is not null)
{
// set status text
bool persist = false;

switch (AppStatus.Code)
{
case StatusCode.ServiceCommandFail:
persist = true;
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statSvcError", (Command)data));
lblStatus.Text = Strings.GetString("statSvcError", (Command)data);
break;
case StatusCode.ServiceResponseEmpty:
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statResponseEmpty"));
lblStatus.Text = Strings.GetString("statResponseEmpty");
break;
case StatusCode.ServiceTimeout:
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statSvcTimeout"));
lblStatus.Text = Strings.GetString("statSvcTimeout");
break;
case StatusCode.NoConfig:
persist = true;
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statNoConf"));
lblStatus.Text = Strings.GetString("statNoConf");
break;
case StatusCode.ConfLoading:
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statConfLoading"));
lblStatus.Text = Strings.GetString("statConfLoading");
break;
case StatusCode.ConfApplySuccess:
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statConfApplied"));
lblStatus.Text = Strings.GetString("statConfApplied");
break;
case StatusCode.FullBlastToggleSuccess:
lblStatus.Invoke(() => lblStatus.Text = Strings.GetString("statFBToggled"));
lblStatus.Text = Strings.GetString("statFBToggled");
break;
default:
persist = true;
lblStatus.Invoke(() => lblStatus.Text = "Ready");
AppStatus.RepeatCount = 0;
lblStatus.Text = "Ready";
break;
}

if (AppStatus.RepeatCount > 0)
{
lblStatus.Invoke(() => lblStatus.Text += $" (x{AppStatus.RepeatCount + 1})");
lblStatus.Text += $" (x{AppStatus.RepeatCount + 1})";
}

tmrStatusReset.Stop();
if (!persist)
{
tmrStatusReset.Start();
}
}
});
}

private void SendServiceMessage(ServiceCommand command)
Expand Down

0 comments on commit 722bc3a

Please sign in to comment.