mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-25 18:53:42 +00:00
Refactor resolving chat log to a separate service to allow reusability across CLI and GUI
This commit is contained in:
@@ -19,7 +19,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IDataService _dataService;
|
||||
private readonly IMessageGroupService _messageGroupService;
|
||||
private readonly IChatLogService _chatLogService;
|
||||
private readonly IExportService _exportService;
|
||||
|
||||
private readonly Dictionary<Guild, IReadOnlyList<Channel>> _guildChannelsMap;
|
||||
@@ -111,12 +111,12 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||
public RelayCommand<Channel> ShowExportSetupCommand { get; }
|
||||
|
||||
public MainViewModel(ISettingsService settingsService, IUpdateService updateService, IDataService dataService,
|
||||
IMessageGroupService messageGroupService, IExportService exportService)
|
||||
IChatLogService chatLogService, IExportService exportService)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
_updateService = updateService;
|
||||
_dataService = dataService;
|
||||
_messageGroupService = messageGroupService;
|
||||
_chatLogService = chatLogService;
|
||||
_exportService = exportService;
|
||||
|
||||
_guildChannelsMap = new Dictionary<Guild, IReadOnlyList<Channel>>();
|
||||
@@ -256,21 +256,11 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: extract this to make it reusable across implementations
|
||||
// Get messages
|
||||
var messages = await _dataService.GetChannelMessagesAsync(token, channel.Id, from, to, progressHandler);
|
||||
|
||||
// Group messages
|
||||
var messageGroups = _messageGroupService.GroupMessages(messages);
|
||||
|
||||
// Get mentionables
|
||||
var mentionables = await _dataService.GetMentionablesAsync(token, guild.Id, messages);
|
||||
|
||||
// Create log
|
||||
var log = new ChatLog(guild, channel, from, to, messageGroups, mentionables);
|
||||
// Get chat log
|
||||
var chatLog = await _chatLogService.GetChatLogAsync(token, guild, channel, from, to, progressHandler);
|
||||
|
||||
// Export
|
||||
_exportService.Export(format, filePath, log);
|
||||
_exportService.Export(format, filePath, chatLog);
|
||||
|
||||
// Open
|
||||
Process.Start(filePath);
|
||||
|
||||
Reference in New Issue
Block a user