mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Cleanup
This commit is contained in:
parent
e29f08264c
commit
aea96d5eba
3 changed files with 13 additions and 16 deletions
|
@ -103,7 +103,7 @@ internal partial class MediaDownloader
|
||||||
// Otherwise, use the original file name but inject the hash in the middle
|
// Otherwise, use the original file name but inject the hash in the middle
|
||||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
|
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
|
||||||
var fileExtension = Path.GetExtension(fileName);
|
var fileExtension = Path.GetExtension(fileName);
|
||||||
|
|
||||||
// Probably not a file extension, just a dot in a long file name
|
// Probably not a file extension, just a dot in a long file name
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/708
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/708
|
||||||
if (fileExtension.Length > 41)
|
if (fileExtension.Length > 41)
|
||||||
|
@ -114,4 +114,4 @@ internal partial class MediaDownloader
|
||||||
|
|
||||||
return PathEx.EscapeFileName(fileNameWithoutExtension.Truncate(42) + '-' + urlHash + fileExtension);
|
return PathEx.EscapeFileName(fileNameWithoutExtension.Truncate(42) + '-' + urlHash + fileExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly DialogManager _dialogManager;
|
private readonly DialogManager _dialogManager;
|
||||||
private readonly SettingsService _settingsService;
|
private readonly SettingsService _settingsService;
|
||||||
|
|
||||||
private readonly AutoResetProgressMuxer _progressMuxer;
|
private readonly AutoResetProgressMuxer _progressMuxer;
|
||||||
|
|
||||||
private DiscordClient? _discord;
|
private DiscordClient? _discord;
|
||||||
|
@ -49,7 +49,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? SelectedChannels { get; set; }
|
public IReadOnlyList<Channel>? SelectedChannels { get; set; }
|
||||||
|
|
||||||
public DashboardViewModel(
|
public DashboardViewModel(
|
||||||
IViewModelFactory viewModelFactory,
|
IViewModelFactory viewModelFactory,
|
||||||
IEventAggregator eventAggregator,
|
IEventAggregator eventAggregator,
|
||||||
|
@ -60,9 +60,9 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
_dialogManager = dialogManager;
|
_dialogManager = dialogManager;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
|
|
||||||
_progressMuxer = Progress.CreateMuxer().WithAutoReset();
|
_progressMuxer = Progress.CreateMuxer().WithAutoReset();
|
||||||
|
|
||||||
this.Bind(o => o.IsBusy, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate));
|
this.Bind(o => o.IsBusy, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate));
|
||||||
Progress.Bind(o => o.Current, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate));
|
Progress.Bind(o => o.Current, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate));
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
Token = _settingsService.LastToken;
|
Token = _settingsService.LastToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ShowSettings()
|
public async void ShowSettings()
|
||||||
{
|
{
|
||||||
var dialog = _viewModelFactory.CreateSettingsViewModel();
|
var dialog = _viewModelFactory.CreateSettingsViewModel();
|
||||||
|
@ -90,7 +90,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
var progress = _progressMuxer.CreateInput();
|
var progress = _progressMuxer.CreateInput();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var token = Token?.Trim('"', ' ');
|
var token = Token?.Trim('"', ' ');
|
||||||
|
@ -136,8 +136,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||||
!IsBusy &&
|
!IsBusy &&
|
||||||
_discord is not null &&
|
_discord is not null &&
|
||||||
SelectedGuild is not null &&
|
SelectedGuild is not null &&
|
||||||
SelectedChannels is not null &&
|
SelectedChannels?.Any() is true;
|
||||||
SelectedChannels.Any();
|
|
||||||
|
|
||||||
public async void ExportChannels()
|
public async void ExportChannels()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,12 +21,11 @@ public class ExportSetupViewModel : DialogScreen
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? Channels { get; set; }
|
public IReadOnlyList<Channel>? Channels { get; set; }
|
||||||
|
|
||||||
public bool IsSingleChannel => Channels is null || Channels.Count == 1;
|
public bool IsSingleChannel => Channels?.Count == 1;
|
||||||
|
|
||||||
public string? OutputPath { get; set; }
|
public string? OutputPath { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<ExportFormat> AvailableFormats =>
|
public IReadOnlyList<ExportFormat> AvailableFormats { get; } = Enum.GetValues<ExportFormat>();
|
||||||
Enum.GetValues(typeof(ExportFormat)).Cast<ExportFormat>().ToArray();
|
|
||||||
|
|
||||||
public ExportFormat SelectedFormat { get; set; }
|
public ExportFormat SelectedFormat { get; set; }
|
||||||
|
|
||||||
|
@ -96,12 +95,11 @@ public class ExportSetupViewModel : DialogScreen
|
||||||
_settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;
|
_settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;
|
||||||
|
|
||||||
// If single channel - prompt file path
|
// If single channel - prompt file path
|
||||||
if (Channels is not null && IsSingleChannel)
|
if (IsSingleChannel)
|
||||||
{
|
{
|
||||||
var channel = Channels.Single();
|
|
||||||
var defaultFileName = ExportRequest.GetDefaultOutputFileName(
|
var defaultFileName = ExportRequest.GetDefaultOutputFileName(
|
||||||
Guild!,
|
Guild!,
|
||||||
channel,
|
Channels!.Single(),
|
||||||
SelectedFormat,
|
SelectedFormat,
|
||||||
After?.Pipe(Snowflake.FromDate),
|
After?.Pipe(Snowflake.FromDate),
|
||||||
Before?.Pipe(Snowflake.FromDate)
|
Before?.Pipe(Snowflake.FromDate)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue