From c4a78caf5b40980092e2cf81cc5c4241d38c5ada Mon Sep 17 00:00:00 2001
From: Exp <17885980+exp111@users.noreply.github.com>
Date: Wed, 11 Oct 2023 14:48:07 +0200
Subject: [PATCH] non functional set token
---
.../ViewModels/MainWindowViewModel.cs | 2 +-
.../ViewModels/SettingsViewModel.cs | 20 +++++++++++++++++++
Turbulence.Desktop/SettingsWindow.axaml | 3 +++
.../Views/Settings/AccountSettingsView.axaml | 8 +++++++-
.../Settings/AccountSettingsView.axaml.cs | 16 +++++++++++++++
5 files changed, 47 insertions(+), 2 deletions(-)
create mode 100644 Turbulence.Core/ViewModels/SettingsViewModel.cs
diff --git a/Turbulence.Core/ViewModels/MainWindowViewModel.cs b/Turbulence.Core/ViewModels/MainWindowViewModel.cs
index e8f3821..1223f5a 100644
--- a/Turbulence.Core/ViewModels/MainWindowViewModel.cs
+++ b/Turbulence.Core/ViewModels/MainWindowViewModel.cs
@@ -65,4 +65,4 @@ public async void Receive(SendMessageMsg message) =>
///
/// Send a message in the currently selected channel
///
-public record SendMessageMsg(string Message);
+public record SendMessageMsg(string Message);
\ No newline at end of file
diff --git a/Turbulence.Core/ViewModels/SettingsViewModel.cs b/Turbulence.Core/ViewModels/SettingsViewModel.cs
new file mode 100644
index 0000000..b34bed9
--- /dev/null
+++ b/Turbulence.Core/ViewModels/SettingsViewModel.cs
@@ -0,0 +1,20 @@
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.Configuration;
+using Turbulence.Discord;
+
+namespace Turbulence.Core.ViewModels;
+
+public partial class SettingsViewModel : ViewModelBase
+{
+ //TODO: save current user?
+
+ [RelayCommand]
+ private void SetToken(string token)
+ {
+ //TODO: run in service?
+ //Messenger.Send(new SetTokenMessage(token));
+ var config = new ConfigurationManager().AddUserSecrets().Build();
+ config["token"] = token;
+ //TODO: actually save it lmao
+ }
+}
diff --git a/Turbulence.Desktop/SettingsWindow.axaml b/Turbulence.Desktop/SettingsWindow.axaml
index e89d7e9..94401fd 100644
--- a/Turbulence.Desktop/SettingsWindow.axaml
+++ b/Turbulence.Desktop/SettingsWindow.axaml
@@ -10,6 +10,9 @@
WindowStartupLocation="CenterOwner"
x:Class="Turbulence.Desktop.SettingsWindow"
Title="Settings">
+
+
+
diff --git a/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml b/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml
index 99f0309..9ac5959 100644
--- a/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml
+++ b/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml
@@ -5,5 +5,11 @@
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="500"
x:Class="Turbulence.Desktop.Views.Settings.AccountSettingsView"
Background="#313338">
- Account
+
+
+
+
+ Show
+
+
diff --git a/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml.cs b/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml.cs
index 38ed309..dac788e 100644
--- a/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml.cs
+++ b/Turbulence.Desktop/Views/Settings/AccountSettingsView.axaml.cs
@@ -1,4 +1,6 @@
using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Turbulence.Core.ViewModels;
namespace Turbulence.Desktop.Views.Settings;
@@ -8,4 +10,18 @@ public AccountSettingsView()
{
InitializeComponent();
}
+
+ public void OnSetToken(object? sender, RoutedEventArgs? e)
+ {
+ ((SettingsViewModel)DataContext!).SetTokenCommand.Execute(Token.Text);
+ Token.Text = "";
+ }
+
+ public void OnTokenShow(object? sender, RoutedEventArgs? e)
+ {
+ if (sender is CheckBox check)
+ {
+ Token.RevealPassword = check.IsChecked ?? false;
+ }
+ }
}