| 1 | using CommunityToolkit.Mvvm.ComponentModel; |
| 2 | using CommunityToolkit.Mvvm.Input; |
| 3 | |
| 4 | namespace CascadeIDE.ViewModels; |
| 5 | |
| 6 | /// <summary>Привязки <c>[intercom.transport]</c> и Connect/Disconnect (ADR 0144).</summary> |
| 7 | public partial class MainWindowViewModel |
| 8 | { |
| 9 | public static readonly IReadOnlyList<string> IntercomOAuthProviderOptions = ["github", "oidc"]; |
| 10 | |
| 11 | [ObservableProperty] private bool _intercomTransportEnabled; |
| 12 | [ObservableProperty] private string _intercomTransportBaseUrl = ""; |
| 13 | [ObservableProperty] private string _intercomTransportLocalServerPath = ""; |
| 14 | [ObservableProperty] private string _intercomTransportTeamId = ""; |
| 15 | [ObservableProperty] private string _intercomTransportDefaultTopicId = ""; |
| 16 | [ObservableProperty] private string _intercomTransportOAuthProvider = "github"; |
| 17 | [ObservableProperty] private string _intercomTransportDevTeamToken = ""; |
| 18 | [ObservableProperty] private int _intercomTransportSseReconnectBackoffMs = 1000; |
| 19 | [ObservableProperty] private bool _intercomTransportAutoConnectOnSend = true; |
| 20 | [ObservableProperty] private bool _intercomTransportSyncAgentChannelMessages = true; |
| 21 | [ObservableProperty] private string _intercomTransportConnectionStatus = ""; |
| 22 | |
| 23 | [RelayCommand] |
| 24 | private async Task ConnectIntercomTransportFromSettingsAsync() |
| 25 | { |
| 26 | var (ok, message) = await ConnectIntercomTeamTransportAsync().ConfigureAwait(false); |
| 27 | IntercomTransportConnectionStatus = message; |
| 28 | if (!ok) |
| 29 | IntercomTransportConnectionStatus = "Ошибка: " + message; |
| 30 | else |
| 31 | IntercomTransportConnectionStatus = IntercomTransport.ConnectionStatus; |
| 32 | } |
| 33 | |
| 34 | [RelayCommand] |
| 35 | private async Task DisconnectIntercomTransportFromSettingsAsync() |
| 36 | { |
| 37 | await DisconnectIntercomTeamTransportAsync().ConfigureAwait(false); |
| 38 | IntercomTransportConnectionStatus = IntercomTransport.ConnectionStatus; |
| 39 | } |
| 40 | } |
| 41 | |