@@ -204,6 +204,11 @@ public string TitleText
204204 {
205205 get
206206 {
207+ if ( NovelList == null )
208+ {
209+ return "NCodeParser" ;
210+ }
211+
207212 return $ "NCodeParser ({ UpdateCount } /{ NovelList . Count } )";
208213 }
209214 }
@@ -223,7 +228,7 @@ public MainViewModel()
223228 InitControls ( ) ;
224229 }
225230
226- private async Task InitInstance ( )
231+ private void InitInstance ( )
227232 {
228233 LoadedCommand = new RelayCommand ( OnLoaded ) ;
229234 AddCommand1 = new RelayCommand ( OnAdd1 , CanAdd1 ) ;
@@ -265,15 +270,27 @@ private async void InitControls()
265270
266271 private async void OnLoaded ( )
267272 {
268- bool canUpdate = await UpdateHelper . CheckUpdate ( ) . ConfigureAwait ( false ) ;
269- if ( canUpdate )
273+ string version = await UpdateHelper . GetLatestVersion ( ) . ConfigureAwait ( false ) ;
274+ if ( string . IsNullOrWhiteSpace ( version ) )
270275 {
271- // TODO
276+ return ;
277+ }
278+
279+ string currentVersion = Config . ApplicationVersion ;
280+ if ( false ) // TODO Compare Version
281+ {
282+ var result = MessageBox . Show ( "TODO" ) ;
272283 }
273284 }
274285
275286 private async Task SetTranslator ( )
276287 {
288+ if ( Downloader == null )
289+ {
290+ Debug . Assert ( false ) ;
291+ return ;
292+ }
293+
277294 if ( Config . TranslatorType == TranslatorType . GSheet )
278295 {
279296 var translator = new GSheetsTranslator ( ) ;
@@ -315,6 +332,12 @@ private async Task SetTranslator()
315332
316333 private async Task SelectNovel ( Novel novel )
317334 {
335+ if ( Downloader == null )
336+ {
337+ Debug . Assert ( false ) ;
338+ return ;
339+ }
340+
318341 if ( novel == null )
319342 {
320343 return ;
@@ -332,7 +355,7 @@ private async Task SelectNovel(Novel novel)
332355 novel . Episodes . Clear ( ) ;
333356 novel . Episodes . AddAll ( Episodes ) ;
334357
335- await App . Current ? . Dispatcher . InvokeAsync ( ( ) =>
358+ await App . Current ? . Dispatcher ? . InvokeAsync ( ( ) =>
336359 {
337360 novel . UIEpisodes . Clear ( ) ;
338361 novel . UIEpisodes . AddAll ( novel . Episodes ) ;
@@ -369,6 +392,12 @@ private void CheckAllUpdate()
369392
370393 private void CheckUpdate ( Novel novel )
371394 {
395+ if ( Downloader == null )
396+ {
397+ Debug . Assert ( false ) ;
398+ return ;
399+ }
400+
372401 if ( novel == null )
373402 {
374403 return ;
@@ -393,7 +422,7 @@ private void CheckUpdate(Novel novel)
393422 novel . Episodes . Clear ( ) ;
394423 novel . Episodes . AddAll ( Episodes ) ;
395424
396- App . Current ? . Dispatcher . InvokeAsync ( ( ) =>
425+ App . Current ? . Dispatcher ? . InvokeAsync ( ( ) =>
397426 {
398427 novel . UIEpisodes . Clear ( ) ;
399428 novel . UIEpisodes . AddAll ( novel . Episodes ) ;
@@ -573,31 +602,37 @@ private bool CanAdd3()
573602
574603 private void OnSelectAll ( )
575604 {
576- if ( SelectedNovel == null )
605+ var novel = SelectedNovel ;
606+ if ( novel == null )
577607 {
578608 MessageBox . Show ( "선택된 소설이 없습니다." ) ;
579609 return ;
580610 }
581611
582- SelectedNovel . EpisodeStartIndex = 0 ;
583- SelectedNovel . EpisodeEndIndex = SelectedNovel . Episodes . Count - 1 ;
612+ if ( novel . Episodes . Count == 0 )
613+ {
614+ return ;
615+ }
616+
617+ novel . EpisodeStartIndex = 0 ;
618+ novel . EpisodeEndIndex = novel . Episodes . Count - 1 ;
584619 }
585620
586621 private async void OnDownload ( )
587622 {
588- if ( SelectedNovel == null )
623+ var novel = SelectedNovel ;
624+ if ( novel == null )
589625 {
590626 MessageBox . Show ( "선택된 소설이 없습니다." ) ;
591627 return ;
592628 }
593629
594- if ( SelectedNovel . Episodes . Count == 0 )
630+ if ( novel . Episodes . Count == 0 )
595631 {
596632 MessageBox . Show ( "다운로드할 수 없습니다." ) ;
597633 return ;
598634 }
599635
600- var novel = SelectedNovel ;
601636 int startIndex = novel . EpisodeStartIndex ;
602637 int endIndex = novel . EpisodeEndIndex ;
603638
@@ -621,7 +656,7 @@ private void OnExplorer()
621656
622657 private void OnExit ( )
623658 {
624- App . Current . MainWindow . Close ( ) ;
659+ App . Current ? . MainWindow ? . Close ( ) ;
625660 }
626661
627662 private void OnShowLicense ( )
0 commit comments