Patch for EchoHub v0.2.12

This commit is contained in:
Stone_Red
2026-07-16 13:37:26 +02:00
parent c79fb1cb33
commit dddf5b6fc7
2 changed files with 36 additions and 10 deletions
+28 -7
View File
@@ -166,8 +166,8 @@ public sealed class ConnectionService : IDisposable
if (entry.Manager.TrackChannel(channelName)) if (entry.Manager.TrackChannel(channelName))
{ {
List<MessageDto> history = await entry.Manager.JoinChannelAsync(channelName); var outcome = await entry.Manager.JoinChannelAsync(channelName);
return history.Select(m => MessageModelFromDto(m, entry)).ToList(); return outcome.History.Select(m => MessageModelFromDto(m, entry)).ToList();
} }
List<MessageDto> existing = await entry.Manager.GetHistoryAsync(channelName); List<MessageDto> existing = await entry.Manager.GetHistoryAsync(channelName);
@@ -357,7 +357,8 @@ public sealed class ConnectionService : IDisposable
await using FileStream stream = File.OpenRead(filePath); await using FileStream stream = File.OpenRead(filePath);
string fileName = Path.GetFileName(filePath); string fileName = Path.GetFileName(filePath);
_ = await entry.ApiClient.UploadFileAsync(channelName, stream, fileName, size); var attachment = new OutgoingAttachment(stream, fileName);
_ = await entry.ApiClient.SendMessageWithAttachmentsAsync(channelName, "", [attachment], size);
} }
public void UpdateChannelTopic(string serverUrl, string channelName, string? topic) public void UpdateChannelTopic(string serverUrl, string channelName, string? topic)
@@ -489,6 +490,26 @@ public sealed class ConnectionService : IDisposable
dto.SenderUsername, dto.SenderUsername,
dto.SenderNicknameColor); dto.SenderNicknameColor);
MessageType type = MessageType.Text;
string? attachmentUrl = null;
string? attachmentFileName = null;
long? attachmentFileSize = null;
if (dto.Attachments is { Count: > 0 })
{
AttachmentDto first = dto.Attachments[0];
type = first.Kind switch
{
AttachmentKind.Image => MessageType.Image,
AttachmentKind.Audio => MessageType.Audio,
AttachmentKind.File => MessageType.File,
_ => MessageType.File
};
attachmentUrl = first.Url;
attachmentFileName = first.FileName;
attachmentFileSize = first.FileSize;
}
return new MessageModel( return new MessageModel(
dto.Id.ToString("N"), dto.Id.ToString("N"),
author, author,
@@ -496,10 +517,10 @@ public sealed class ConnectionService : IDisposable
dto.Content, dto.Content,
dto.ChannelName, dto.ChannelName,
entry.Server.ServerUrl, entry.Server.ServerUrl,
dto.Type, type,
dto.AttachmentUrl, attachmentUrl,
dto.AttachmentFileName, attachmentFileName,
dto.AttachmentFileSize); attachmentFileSize);
} }
internal ServerConnection? GetConnection(string serverUrl) internal ServerConnection? GetConnection(string serverUrl)
+8 -3
View File
@@ -154,7 +154,7 @@ public sealed class MainWindowViewModel : ViewModelBase
return Task.CompletedTask; return Task.CompletedTask;
}; };
_commandHandler.OnJoinChannel += async channelName => _commandHandler.OnJoinChannel += async (channelName, password) =>
{ {
string serverUrl = GetCurrentServerUrl(); string serverUrl = GetCurrentServerUrl();
if (string.IsNullOrEmpty(serverUrl)) if (string.IsNullOrEmpty(serverUrl))
@@ -669,9 +669,10 @@ public sealed class MainWindowViewModel : ViewModelBase
await ConnectionService.ConnectWithSavedTokenAsync( await ConnectionService.ConnectWithSavedTokenAsync(
saved.Url, saved.Username, saved.RefreshToken, saved.RememberMe); saved.Url, saved.Username, saved.RefreshToken, saved.RememberMe);
} }
catch catch (Exception ex)
{ {
serverVm.IsConnecting = false; serverVm.IsConnecting = false;
StatusText = $"Auto-connect failed for {saved.Name}: {ex.Message}";
} }
} }
@@ -692,8 +693,12 @@ public sealed class MainWindowViewModel : ViewModelBase
} }
catch (Exception ex) catch (Exception ex)
{ {
StatusText = $"Connection failed: {ex.Message}";
serverVm.IsConnecting = false; serverVm.IsConnecting = false;
var box = MessageBoxManager.GetMessageBoxStandard(
"Connection Failed",
$"Could not connect to server:\n{ex.Message}",
ButtonEnum.Ok);
await box.ShowWindowDialogAsync(_mainWindow);
} }
} }