Example #1
0
        public async Task GetFavoritesApi(bool read, FavoritesTabModel tab, bool backward)
        {
            this.CheckAccountState();

            var count = GetApiResultCount(MyCommon.WORKERTYPE.Favorites, backward, false);

            TwitterStatus[] statuses;
            if (backward)
            {
                statuses = await this.Api.FavoritesList(count, maxId: tab.OldestId)
                    .ConfigureAwait(false);
            }
            else
            {
                statuses = await this.Api.FavoritesList(count)
                    .ConfigureAwait(false);
            }

            var minimumId = this.CreateFavoritePostsFromJson(statuses, read);

            if (minimumId != null)
                tab.OldestId = minimumId.Value;
        }
Example #2
0
        private void LoadConfig()
        {
            _cfgCommon = SettingCommon.Load();
            SettingCommon.Instance = this._cfgCommon;
            if (_cfgCommon.UserAccounts == null || _cfgCommon.UserAccounts.Count == 0)
            {
                _cfgCommon.UserAccounts = new List<UserAccount>();
                if (!string.IsNullOrEmpty(_cfgCommon.UserName))
                {
                    UserAccount account = new UserAccount();
                    account.Username = _cfgCommon.UserName;
                    account.UserId = _cfgCommon.UserId;
                    account.Token = _cfgCommon.Token;
                    account.TokenSecret = _cfgCommon.TokenSecret;

                    _cfgCommon.UserAccounts.Add(account);
                }
            }

            _cfgLocal = SettingLocal.Load();

            // v1.2.4 以前の設定には ScaleDimension の項目がないため、現在の DPI と同じとして扱う
            if (_cfgLocal.ScaleDimension.IsEmpty)
                _cfgLocal.ScaleDimension = this.CurrentAutoScaleDimensions;

            var tabsSetting = SettingTabs.Load().Tabs;
            foreach (var tabSetting in tabsSetting)
            {
                TabModel tab;
                switch (tabSetting.TabType)
                {
                    case MyCommon.TabUsageType.Home:
                        tab = new HomeTabModel(tabSetting.TabName);
                        break;
                    case MyCommon.TabUsageType.Mentions:
                        tab = new MentionsTabModel(tabSetting.TabName);
                        break;
                    case MyCommon.TabUsageType.DirectMessage:
                        tab = new DirectMessagesTabModel(tabSetting.TabName);
                        break;
                    case MyCommon.TabUsageType.Favorites:
                        tab = new FavoritesTabModel(tabSetting.TabName);
                        break;
                    case MyCommon.TabUsageType.UserDefined:
                        tab = new FilterTabModel(tabSetting.TabName);
                        break;
                    case MyCommon.TabUsageType.UserTimeline:
                        tab = new UserTimelineTabModel(tabSetting.TabName, tabSetting.User);
                        break;
                    case MyCommon.TabUsageType.PublicSearch:
                        tab = new PublicSearchTabModel(tabSetting.TabName)
                        {
                            SearchWords = tabSetting.SearchWords,
                            SearchLang = tabSetting.SearchLang,
                        };
                        break;
                    case MyCommon.TabUsageType.Lists:
                        tab = new ListTimelineTabModel(tabSetting.TabName, tabSetting.ListInfo);
                        break;
                    case MyCommon.TabUsageType.Mute:
                        tab = new MuteTabModel(tabSetting.TabName);
                        break;
                    default:
                        continue;
                }

                tab.UnreadManage = tabSetting.UnreadManage;
                tab.Protected = tabSetting.Protected;
                tab.Notify = tabSetting.Notify;
                tab.SoundFile = tabSetting.SoundFile;

                if (tab.IsDistributableTabType)
                {
                    var filterTab = (FilterTabModel)tab;
                    filterTab.FilterArray = tabSetting.FilterArray;
                    filterTab.FilterModified = false;
                }

                if (this._statuses.ContainsTab(tab.TabName))
                    tab.TabName = this._statuses.MakeTabName("MyTab");

                this._statuses.AddTab(tab);
            }
            if (_statuses.Tabs.Count == 0)
            {
                _statuses.AddTab(new HomeTabModel());
                _statuses.AddTab(new MentionsTabModel());
                _statuses.AddTab(new DirectMessagesTabModel());
                _statuses.AddTab(new FavoritesTabModel());
            }
        }