mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
Remove some views and replace them with snackbar notifications
This commit is contained in:
parent
63e3ba8891
commit
656e5a5b0d
12 changed files with 10 additions and 181 deletions
|
@ -7,8 +7,6 @@ namespace DiscordChatExporter.Gui
|
||||||
{
|
{
|
||||||
public class Container
|
public class Container
|
||||||
{
|
{
|
||||||
public IErrorViewModel ErrorViewModel => Resolve<IErrorViewModel>();
|
|
||||||
public IExportDoneViewModel ExportDoneViewModel => Resolve<IExportDoneViewModel>();
|
|
||||||
public IExportSetupViewModel ExportSetupViewModel => Resolve<IExportSetupViewModel>();
|
public IExportSetupViewModel ExportSetupViewModel => Resolve<IExportSetupViewModel>();
|
||||||
public IMainViewModel MainViewModel => Resolve<IMainViewModel>();
|
public IMainViewModel MainViewModel => Resolve<IMainViewModel>();
|
||||||
public ISettingsViewModel SettingsViewModel => Resolve<ISettingsViewModel>();
|
public ISettingsViewModel SettingsViewModel => Resolve<ISettingsViewModel>();
|
||||||
|
@ -31,8 +29,6 @@ namespace DiscordChatExporter.Gui
|
||||||
SimpleIoc.Default.Register<IUpdateService, UpdateService>();
|
SimpleIoc.Default.Register<IUpdateService, UpdateService>();
|
||||||
|
|
||||||
// View models
|
// View models
|
||||||
SimpleIoc.Default.Register<IErrorViewModel, ErrorViewModel>(true);
|
|
||||||
SimpleIoc.Default.Register<IExportDoneViewModel, ExportDoneViewModel>(true);
|
|
||||||
SimpleIoc.Default.Register<IExportSetupViewModel, ExportSetupViewModel>(true);
|
SimpleIoc.Default.Register<IExportSetupViewModel, ExportSetupViewModel>(true);
|
||||||
SimpleIoc.Default.Register<IMainViewModel, MainViewModel>(true);
|
SimpleIoc.Default.Register<IMainViewModel, MainViewModel>(true);
|
||||||
SimpleIoc.Default.Register<ISettingsViewModel, SettingsViewModel>(true);
|
SimpleIoc.Default.Register<ISettingsViewModel, SettingsViewModel>(true);
|
||||||
|
|
|
@ -79,26 +79,17 @@
|
||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Messages\ShowErrorMessage.cs" />
|
|
||||||
<Compile Include="Messages\ShowExportDoneMessage.cs" />
|
|
||||||
<Compile Include="Messages\ShowExportSetupMessage.cs" />
|
<Compile Include="Messages\ShowExportSetupMessage.cs" />
|
||||||
<Compile Include="Messages\ShowNotificationMessage.cs" />
|
<Compile Include="Messages\ShowNotificationMessage.cs" />
|
||||||
<Compile Include="Messages\ShowSettingsMessage.cs" />
|
<Compile Include="Messages\ShowSettingsMessage.cs" />
|
||||||
<Compile Include="Messages\StartExportMessage.cs" />
|
<Compile Include="Messages\StartExportMessage.cs" />
|
||||||
<Compile Include="ViewModels\ErrorViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\ExportSetupViewModel.cs" />
|
<Compile Include="ViewModels\ExportSetupViewModel.cs" />
|
||||||
<Compile Include="ViewModels\IErrorViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\IExportSetupViewModel.cs" />
|
<Compile Include="ViewModels\IExportSetupViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ISettingsViewModel.cs" />
|
<Compile Include="ViewModels\ISettingsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\IExportDoneViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ExportDoneViewModel.cs" />
|
|
||||||
<Compile Include="Views\ErrorDialog.ammy.cs">
|
<Compile Include="Views\ErrorDialog.ammy.cs">
|
||||||
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\ExportDoneDialog.ammy.cs">
|
|
||||||
<DependentUpon>ExportDoneDialog.ammy</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\ExportSetupDialog.ammy.cs">
|
<Compile Include="Views\ExportSetupDialog.ammy.cs">
|
||||||
<DependentUpon>ExportSetupDialog.ammy</DependentUpon>
|
<DependentUpon>ExportSetupDialog.ammy</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -115,11 +106,6 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
<DependentUpon>ErrorDialog.ammy</DependentUpon>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\ExportDoneDialog.g.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<DependentUpon>ExportDoneDialog.ammy</DependentUpon>
|
|
||||||
</Page>
|
|
||||||
<Page Include="Views\ExportSetupDialog.g.xaml">
|
<Page Include="Views\ExportSetupDialog.g.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -165,7 +151,6 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</None>
|
</None>
|
||||||
<None Include="Views\ErrorDialog.ammy" />
|
<None Include="Views\ErrorDialog.ammy" />
|
||||||
<None Include="Views\ExportDoneDialog.ammy" />
|
|
||||||
<None Include="Views\ExportSetupDialog.ammy" />
|
<None Include="Views\ExportSetupDialog.ammy" />
|
||||||
<None Include="Views\MainWindow.ammy" />
|
<None Include="Views\MainWindow.ammy" />
|
||||||
<None Include="Views\SettingsDialog.ammy" />
|
<None Include="Views\SettingsDialog.ammy" />
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
namespace DiscordChatExporter.Gui.Messages
|
|
||||||
{
|
|
||||||
public class ShowErrorMessage
|
|
||||||
{
|
|
||||||
public string Message { get; }
|
|
||||||
|
|
||||||
public ShowErrorMessage(string message)
|
|
||||||
{
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
namespace DiscordChatExporter.Gui.Messages
|
|
||||||
{
|
|
||||||
public class ShowExportDoneMessage
|
|
||||||
{
|
|
||||||
public string FilePath { get; }
|
|
||||||
|
|
||||||
public ShowExportDoneMessage(string filePath)
|
|
||||||
{
|
|
||||||
FilePath = filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
using DiscordChatExporter.Gui.Messages;
|
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.ViewModels
|
|
||||||
{
|
|
||||||
public class ErrorViewModel : ViewModelBase, IErrorViewModel
|
|
||||||
{
|
|
||||||
public string Message { get; private set; }
|
|
||||||
|
|
||||||
public ErrorViewModel()
|
|
||||||
{
|
|
||||||
// Messages
|
|
||||||
MessengerInstance.Register<ShowErrorMessage>(this, m =>
|
|
||||||
{
|
|
||||||
Message = m.Message;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
using System.Diagnostics;
|
|
||||||
using DiscordChatExporter.Gui.Messages;
|
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.ViewModels
|
|
||||||
{
|
|
||||||
public class ExportDoneViewModel : ViewModelBase, IExportDoneViewModel
|
|
||||||
{
|
|
||||||
private string _filePath;
|
|
||||||
|
|
||||||
// Commands
|
|
||||||
public RelayCommand OpenCommand { get; }
|
|
||||||
|
|
||||||
public ExportDoneViewModel()
|
|
||||||
{
|
|
||||||
// Commands
|
|
||||||
OpenCommand = new RelayCommand(Open);
|
|
||||||
|
|
||||||
// Messages
|
|
||||||
MessengerInstance.Register<ShowExportDoneMessage>(this, m =>
|
|
||||||
{
|
|
||||||
_filePath = m.FilePath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Open()
|
|
||||||
{
|
|
||||||
Process.Start(_filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
namespace DiscordChatExporter.Gui.ViewModels
|
|
||||||
{
|
|
||||||
public interface IErrorViewModel
|
|
||||||
{
|
|
||||||
string Message { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.ViewModels
|
|
||||||
{
|
|
||||||
public interface IExportDoneViewModel
|
|
||||||
{
|
|
||||||
RelayCommand OpenCommand { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -132,8 +132,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
// Notify user
|
// Notify user
|
||||||
MessengerInstance.Send(
|
MessengerInstance.Send(
|
||||||
new ShowNotificationMessage(
|
new ShowNotificationMessage(
|
||||||
$"DiscordChatExporter v{lastVersion} has been downloaded. " +
|
$"DiscordChatExporter v{lastVersion} has been downloaded – it will be installed when you exit",
|
||||||
"It will be installed once you exit.",
|
|
||||||
"INSTALL NOW",
|
"INSTALL NOW",
|
||||||
async () =>
|
async () =>
|
||||||
{
|
{
|
||||||
|
@ -186,13 +185,13 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
}
|
}
|
||||||
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized)
|
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
const string message = "Unauthorized to perform request. Make sure token is valid.";
|
const string message = "Unauthorized – make sure the token is valid";
|
||||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||||
}
|
}
|
||||||
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
|
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
|
||||||
{
|
{
|
||||||
const string message = "Forbidden to perform request. The account may be locked by 2FA.";
|
const string message = "Forbidden – account may be locked by 2FA";
|
||||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
AvailableGuilds = _guildChannelsMap.Keys.ToArray();
|
AvailableGuilds = _guildChannelsMap.Keys.ToArray();
|
||||||
|
@ -237,12 +236,14 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
await _exportService.ExportAsync(format, filePath, log);
|
await _exportService.ExportAsync(format, filePath, log);
|
||||||
|
|
||||||
// Notify completion
|
// Notify completion
|
||||||
MessengerInstance.Send(new ShowExportDoneMessage(filePath));
|
MessengerInstance.Send(new ShowNotificationMessage($"Export completed for channel [{channel.Name}]",
|
||||||
|
"OPEN",
|
||||||
|
() => Process.Start(filePath)));
|
||||||
}
|
}
|
||||||
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
|
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
|
||||||
{
|
{
|
||||||
const string message = "Forbidden to view messages in that channel.";
|
const string message = "You don't have access to that channel";
|
||||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
using MaterialDesignThemes.Wpf
|
|
||||||
|
|
||||||
UserControl "DiscordChatExporter.Gui.Views.ExportDoneDialog" {
|
|
||||||
DataContext: bind ExportDoneViewModel from $resource Container
|
|
||||||
Width: 250
|
|
||||||
|
|
||||||
StackPanel {
|
|
||||||
// Message
|
|
||||||
TextBlock {
|
|
||||||
Margin: 16
|
|
||||||
FontSize: 16
|
|
||||||
TextWrapping: WrapWithOverflow
|
|
||||||
Text: "Finished exporting chat log"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Buttons
|
|
||||||
@StackPanelHorizontal {
|
|
||||||
HorizontalAlignment: Right
|
|
||||||
|
|
||||||
// Open
|
|
||||||
Button "OpenButton" {
|
|
||||||
Margin: 8
|
|
||||||
Click: OpenButton_Click
|
|
||||||
Command: bind OpenCommand
|
|
||||||
Content: "OPEN"
|
|
||||||
IsDefault: true
|
|
||||||
Style: resource dyn "MaterialDesignFlatButton"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dismiss
|
|
||||||
Button {
|
|
||||||
Margin: 8
|
|
||||||
Command: DialogHost.CloseDialogCommand
|
|
||||||
Content: "DISMISS"
|
|
||||||
IsCancel: true
|
|
||||||
Style: resource dyn "MaterialDesignFlatButton"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
using MaterialDesignThemes.Wpf;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.Views
|
|
||||||
{
|
|
||||||
public partial class ExportDoneDialog
|
|
||||||
{
|
|
||||||
public ExportDoneDialog()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenButton_Click(object sender, RoutedEventArgs args)
|
|
||||||
{
|
|
||||||
DialogHost.CloseDialogCommand.Execute(null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,10 +21,6 @@ namespace DiscordChatExporter.Gui.Views
|
||||||
m => Snackbar.MessageQueue.Enqueue(m.Message, m.CallbackCaption, m.Callback));
|
m => Snackbar.MessageQueue.Enqueue(m.Message, m.CallbackCaption, m.Callback));
|
||||||
|
|
||||||
// Dialog messages
|
// Dialog messages
|
||||||
Messenger.Default.Register<ShowErrorMessage>(this,
|
|
||||||
m => DialogHost.Show(new ErrorDialog()).Forget());
|
|
||||||
Messenger.Default.Register<ShowExportDoneMessage>(this,
|
|
||||||
m => DialogHost.Show(new ExportDoneDialog()).Forget());
|
|
||||||
Messenger.Default.Register<ShowExportSetupMessage>(this,
|
Messenger.Default.Register<ShowExportSetupMessage>(this,
|
||||||
m => DialogHost.Show(new ExportSetupDialog()).Forget());
|
m => DialogHost.Show(new ExportSetupDialog()).Forget());
|
||||||
Messenger.Default.Register<ShowSettingsMessage>(this,
|
Messenger.Default.Register<ShowSettingsMessage>(this,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue