@@ -17,9 +17,6 @@ public partial class DiscordBotViewModel(DiscordBotService botService) : Observa
1717{
1818 private readonly DiscordBotService _botService = botService ;
1919 private readonly DispatcherQueue _dispatcher = DispatcherQueue . GetForCurrentThread ( ) ;
20- private readonly ScheduleTimer _timer = new ( ) ;
21- private TimeSpan _scheduleTime1 = TimeSpan . FromHours ( 12 ) ;
22- private TimeSpan _scheduleTime2 = TimeSpan . FromHours ( 0 ) ;
2320
2421 private GuildSettingsModel ? _selectedGuild ;
2522
@@ -31,69 +28,13 @@ public partial class DiscordBotViewModel(DiscordBotService botService) : Observa
3128
3229 public bool IsDisconnected => ! IsConnected ;
3330
34- public bool IsTimerRunning
35- {
36- get => _timer ? . IsRunning ?? false ;
37- set
38- {
39- if ( value )
40- {
41- _timer ? . Start ( ) ;
42- }
43- else
44- {
45- _timer ? . Stop ( ) ;
46- }
47- OnPropertyChanged ( ) ;
48- }
49- }
50-
51- public TimeSpan ScheduleTime1
52- {
53- get => _scheduleTime1 ;
54- set
55- {
56- if ( SetProperty ( ref _scheduleTime1 , value ) )
57- {
58- UpdateTimer ( ) ;
59- LocalSettingsHelper . SaveSetting ( nameof ( ScheduleTime1 ) , ScheduleTime1 ) ;
60- }
61- }
62- }
63-
64- public TimeSpan ScheduleTime2
65- {
66- get => _scheduleTime2 ;
67- set
68- {
69- if ( SetProperty ( ref _scheduleTime2 , value ) )
70- {
71- UpdateTimer ( ) ;
72- LocalSettingsHelper . SaveSetting ( nameof ( ScheduleTime2 ) , ScheduleTime2 ) ;
73- }
74- }
75- }
76-
77- private void ConfigureTimer ( )
78- {
79- _timer . Tick -= TimerTick ;
80- _timer . Tick += TimerTick ;
81-
82- _scheduleTime1 = LocalSettingsHelper . ReadSetting ( nameof ( ScheduleTime1 ) , TimeSpan . FromHours ( 12 ) ) ;
83- _scheduleTime2 = LocalSettingsHelper . ReadSetting ( nameof ( ScheduleTime2 ) , TimeSpan . FromHours ( 0 ) ) ;
84- OnPropertyChanged ( nameof ( ScheduleTime1 ) ) ;
85- OnPropertyChanged ( nameof ( ScheduleTime2 ) ) ;
86- UpdateTimer ( ) ;
87- }
88-
8931 [ RelayCommand ]
9032 private async Task ConnectBot ( )
9133 {
9234 if ( await _botService . ConnectAsync ( ) )
9335 {
9436 IsConnected = true ;
9537 await LoadAsync ( ) ;
96- ConfigureTimer ( ) ;
9738 }
9839 }
9940
@@ -103,7 +44,6 @@ private async Task DisconnectBot()
10344 CancelUpdateRank ( ) ;
10445 await _botService . DisconnectAsync ( ) ;
10546 IsConnected = false ;
106- _timer . Stop ( ) ;
10747 }
10848
10949 private async Task LoadAsync ( bool forceRefresh = false )
@@ -146,13 +86,6 @@ private async void TimerTick(object? sender, EventArgs e)
14686 }
14787 }
14888
149- private void UpdateTimer ( )
150- {
151- _timer . ClearCheckPoints ( ) ;
152- _timer . AddCheckPoint ( ScheduleTime1 ) ;
153- _timer . AddCheckPoint ( ScheduleTime2 ) ;
154- }
155-
15689 #region Ranking commands
15790
15891 [ ObservableProperty ]
0 commit comments