private async void AddExecute() { var dialog = new ProxyPopup(); var confirm = await dialog.ShowQueuedAsync(); if (confirm != ContentDialogResult.Primary) { return; } var response = await ProtoService.SendAsync(new AddProxy(dialog.Server, dialog.Port, false, dialog.Type)); if (response is Proxy proxy) { var connection = new ProxyViewModel(proxy); Items.Add(connection); await UpdateAsync(connection); } }
private async void EditExecute(ConnectionViewModel connection) { var dialog = new ProxyPopup(connection as ProxyViewModel); var confirm = await dialog.ShowQueuedAsync(); if (confirm != ContentDialogResult.Primary) { return; } var response = await ProtoService.SendAsync(new EditProxy(connection.Id, dialog.Server, dialog.Port, false, dialog.Type)); if (response is Proxy proxy) { var index = Items.IndexOf(connection); Items.Remove(connection); var edited = new ProxyViewModel(proxy); Items.Insert(index, edited); await UpdateAsync(edited); } Handle(CacheService.GetConnectionState(), CacheService.Options.EnabledProxyId); }