internal void EditSelectedSubscription(SubscriptionSettingViewModel selected) { IsEditingSubscription = true; IsSubscriptionPopupOpen = true; NewUrlText = selected.Url; NewNameText = selected.Name ?? ""; }
internal void MoveSelectedSubscription(SubscriptionSettingViewModel selected, int toAdd) { int currentIndex = SubscriptionList.IndexOf(selected); if (currentIndex < 0) { // not found in list return; } int newIndex = currentIndex + toAdd; if (newIndex == currentIndex || newIndex < 0 || newIndex >= SubscriptionList.Count) { return; } SubscriptionList.Move(currentIndex, newIndex); SubscriptionsChanged = true; }
/// <summary> /// Adds or Edits subscription and closes subscription popup /// </summary> internal bool SaveSubscription() { if (!NewUrlText.StartsWith("iros://")) { StatusMessage = ResourceHelper.Get(StringKey.UrlMustBeInIrosFormat); return(false); } if (!SubscriptionList.Any(s => s.Url == NewUrlText)) { IsResolvingName = true; SubscriptionNameHintText = ResourceHelper.Get(StringKey.ResolvingCatalogName); ResolveCatalogNameFromUrl(NewUrlText, resolvedName => { NewNameText = resolvedName; App.Current.Dispatcher.Invoke(() => { SubscriptionList.Add(new SubscriptionSettingViewModel(NewUrlText, NewNameText)); CloseSubscriptionPopup(); IsResolvingName = false; ListDataChanged?.Invoke(); }); }); } else if (IsEditingSubscription) { SubscriptionSettingViewModel toEdit = SubscriptionList.FirstOrDefault(s => s.Url == NewUrlText); toEdit.Name = NewNameText; CloseSubscriptionPopup(); ListDataChanged?.Invoke(); } else { // if user is trying to add a url that already exists in list then just close popup CloseSubscriptionPopup(); return(true); } SubscriptionsChanged = true; return(true); }
internal void RemoveSelectedSubscription(SubscriptionSettingViewModel selected) { SubscriptionsChanged = true; SubscriptionList.Remove(selected); ListDataChanged?.Invoke(); }