void SetMessageNotifyPref(NotificationType type, int account) { if (messageFirstChange) { messageFirstChange = false; return; } Config.Accounts[account].Preferences.MessagesPreferences = type; if (type == NotificationType.None) { PushNotifications.UnregisterPushChannel(Config.Accounts[account], "messages"); } else { PushNotifications.AutoRegisterForNotifications(); } }
public DefaultModel() : base("Default") { SelectedFontSize = FontSizeToIndex(((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize); RetweetsAsMentions = Config.RetweetAsMentions == true; BackgroundUpdateTiles = Config.BackgroundLoadColumns == true; if (Config.TweetsPerRequest == null) { Config.TweetsPerRequest = 40; } TweetsPerRequest = Config.TweetsPerRequest.ToString(); Accounts = new SafeObservable <UserToken>(Config.Accounts); NotifyOptions = new List <string> { Resources.None, Resources.OnlyTile, Resources.ToastAndTile }; SelectedMuteTime = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime); ShowResumePositionButton = Config.RecoverReadPositions == true; GeoTaggingEnabled = Config.EnabledGeolocation == true; SelectedReloadOption = (int)Config.ReloadOptions; PushAvailable = TrialInformation.IsFullFeatured; PushEnabled = PushAvailable && (Config.PushEnabled == true); if (Config.ReadLaterCredentials.Instapaper != null) { InstapaperUser = Config.ReadLaterCredentials.Instapaper.User; InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password; } if (Config.ReadLaterCredentials.Pocket != null) { PocketUser = Config.ReadLaterCredentials.Pocket.User; PocketPassword = Config.ReadLaterCredentials.Pocket.Password; } this.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "RetweetsAsMentions": Config.RetweetAsMentions = RetweetsAsMentions; break; case "BackgroundUpdateTiles": Config.BackgroundLoadColumns = BackgroundUpdateTiles; break; case "TweetsPerRequest": int number; if (int.TryParse(TweetsPerRequest, out number)) { Config.TweetsPerRequest = number; } break; case "SelectedAccount": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { int newOption; newOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences; if (newOption != MentionNotifyOption) { mentionFirstChange = true; MentionNotifyOption = newOption; } newOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences; if (newOption != MessageNotifyOption) { messageFirstChange = true; MessageNotifyOption = newOption; } } break; case "MentionNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { SetMentionNotifyPref((NotificationType)MentionNotifyOption, SelectedAccount); } break; case "MessageNotifyOption": if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count) { SetMessageNotifyPref((NotificationType)MessageNotifyOption, SelectedAccount); } Config.SaveAccounts(); break; case "SelectedMuteTime": Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime); break; case "SelectedFontSize": ((GlobalSettings)App.Current.Resources["GlobalSettings"]). TweetFontSize = IndexToFontSize(SelectedFontSize); break; case "ShowResumePositionButton": Config.RecoverReadPositions = ShowResumePositionButton; break; case "GeoTaggingEnabled": Config.EnabledGeolocation = GeoTaggingEnabled; break; case "PushEnabled": if (!TrialInformation.IsFullFeatured) { if (PushEnabled) { TrialInformation.ShowBuyDialog(); PushEnabled = false; } return; } Config.PushEnabled = PushEnabled; if (PushEnabled == false) { PushNotifications.UnregisterAll(); } else { PushNotifications.AutoRegisterForNotifications(); } break; case "SelectedReloadOption": Config.ReloadOptions = (ColumnReloadOptions)SelectedReloadOption; break; } }; SelectedAccount = -1; if (Config.Accounts.Count > 0) { SelectedAccount = 0; } SetCommands(); }