mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-28 00:36:00 +00:00
Remove some views and replace them with snackbar notifications
This commit is contained in:
@@ -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
|
||||
MessengerInstance.Send(
|
||||
new ShowNotificationMessage(
|
||||
$"DiscordChatExporter v{lastVersion} has been downloaded. " +
|
||||
"It will be installed once you exit.",
|
||||
$"DiscordChatExporter v{lastVersion} has been downloaded – it will be installed when you exit",
|
||||
"INSTALL NOW",
|
||||
async () =>
|
||||
{
|
||||
@@ -186,13 +185,13 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||
}
|
||||
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
const string message = "Unauthorized to perform request. Make sure token is valid.";
|
||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
||||
const string message = "Unauthorized – make sure the token is valid";
|
||||
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||
}
|
||||
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
const string message = "Forbidden to perform request. The account may be locked by 2FA.";
|
||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
||||
const string message = "Forbidden – account may be locked by 2FA";
|
||||
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||
}
|
||||
|
||||
AvailableGuilds = _guildChannelsMap.Keys.ToArray();
|
||||
@@ -237,12 +236,14 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||
await _exportService.ExportAsync(format, filePath, log);
|
||||
|
||||
// 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)
|
||||
{
|
||||
const string message = "Forbidden to view messages in that channel.";
|
||||
MessengerInstance.Send(new ShowErrorMessage(message));
|
||||
const string message = "You don't have access to that channel";
|
||||
MessengerInstance.Send(new ShowNotificationMessage(message));
|
||||
}
|
||||
|
||||
IsBusy = false;
|
||||
|
||||
Reference in New Issue
Block a user