OSDN Git Service

string.IsNullOrEmpty の nullable annotation あり版のメソッドを追加
[opentween/open-tween.git] / OpenTween / Models / PublicSearchTabModel.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 //           (c) 2008-2011 Moz (@syo68k)
4 //           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 //           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 //           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 //           (c) 2011      Egtra (@egtra) <http://dev.activebasic.com/egtra/>
8 //           (c) 2012      kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
9 // All rights reserved.
10 //
11 // This file is part of OpenTween.
12 //
13 // This program is free software; you can redistribute it and/or modify it
14 // under the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 3 of the License, or (at your option)
16 // any later version.
17 //
18 // This program is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
25 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
26 // Boston, MA 02110-1301, USA.
27
28 #nullable enable
29
30 using System;
31 using System.Collections.Generic;
32 using System.Linq;
33 using System.Text;
34 using System.Threading.Tasks;
35 using OpenTween.Setting;
36
37 namespace OpenTween.Models
38 {
39     public class PublicSearchTabModel : InternalStorageTabModel
40     {
41         public override MyCommon.TabUsageType TabType
42             => MyCommon.TabUsageType.PublicSearch;
43
44         public string SearchWords
45         {
46             get => this._searchWords;
47             set
48             {
49                 this._searchWords = value;
50                 this.ResetFetchIds();
51             }
52         }
53
54         public string SearchLang
55         {
56             get => this._searchLang;
57             set
58             {
59                 this._searchLang = value;
60                 this.ResetFetchIds();
61             }
62         }
63
64         private string _searchWords = "";
65         private string _searchLang = "";
66
67         public PublicSearchTabModel(string tabName) : base(tabName)
68         {
69         }
70
71         public override async Task RefreshAsync(Twitter tw, bool backward, bool startup, IProgress<string> progress)
72         {
73             if (MyCommon.IsNullOrEmpty(this.SearchWords))
74                 return;
75
76             bool read;
77             if (!SettingManager.Common.UnreadManage)
78                 read = true;
79             else
80                 read = startup && SettingManager.Common.Read;
81
82             progress.Report("Search refreshing...");
83
84             await tw.GetSearch(read, this, backward)
85                 .ConfigureAwait(false);
86
87             TabInformations.GetInstance().DistributePosts();
88
89             progress.Report("Search refreshed");
90         }
91     }
92 }