You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
using System.Linq; |
|
using Avalonia.Controls; |
|
using StabilityMatrix.Avalonia.Controls; |
|
using StabilityMatrix.Avalonia.Models; |
|
using StabilityMatrix.Avalonia.ViewModels.Settings; |
|
using StabilityMatrix.Core.Attributes; |
|
using StabilityMatrix.Core.Models.Update; |
|
|
|
namespace StabilityMatrix.Avalonia.Views.Settings; |
|
|
|
[Singleton] |
|
public partial class UpdateSettingsPage : UserControlBase |
|
{ |
|
public UpdateSettingsPage() |
|
{ |
|
InitializeComponent(); |
|
} |
|
|
|
private void ChannelListBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) |
|
{ |
|
var listBox = (ListBox)sender!; |
|
|
|
if (e.AddedItems.Count == 0 || e.AddedItems[0] is not UpdateChannelCard item) |
|
{ |
|
return; |
|
} |
|
|
|
var vm = (UpdateSettingsViewModel)DataContext!; |
|
|
|
if (!vm.VerifyChannelSelection(item)) |
|
{ |
|
listBox.Selection.Clear(); |
|
|
|
listBox.Selection.SelectedItem = vm.AvailableUpdateChannelCards.First( |
|
c => c.UpdateChannel == UpdateChannel.Stable |
|
); |
|
|
|
vm.ShowLoginRequiredDialog(); |
|
} |
|
} |
|
}
|
|
|