Code cleanup

This commit is contained in:
Stone_Red
2026-07-18 17:21:36 +02:00
parent 59f6f1d1bd
commit 92cd2bf332
17 changed files with 47 additions and 31 deletions
+9
View File
@@ -32,14 +32,23 @@ public sealed class ChannelJoinResult
public sealed class ConnectionService : IConnectionService
{
public event Action<ServerModel>? ServerAdded;
public event Action<string>? ServerRemoved;
public event Action<ServerModel>? ServerStateChanged;
public event Action<string, ChannelModel>? ChannelAdded;
public event Action<string, string>? ChannelRemoved;
public event Action<string, MessageModel>? MessageReceived;
public event Action<string, string, string?>? UserJoined;
public event Action<string, string>? UserLeft;
public event Action<string, string>? ErrorOccurred;
public event Action<string, string>? ChannelDeleted;
private readonly Dictionary<string, ServerConnection> _connections = new(StringComparer.OrdinalIgnoreCase);
+1
View File
@@ -3,5 +3,6 @@ namespace Decho.Services;
public interface IAttachmentService
{
Task<string?> DownloadAttachmentAsync(string serverUrl, string channelName, string relativeUrl, string fileName);
Task<byte[]?> DownloadImageBytesAsync(string serverUrl, string channelName, string relativeUrl);
}
@@ -3,7 +3,10 @@ namespace Decho.Services;
public interface IConfigPersistenceService
{
void SaveRefreshToken(string serverUrl, string token, string userId);
void RemoveServerFromConfig(string serverUrl);
void RemoveFromLeftChannels(string serverUrl, string channelName);
void AddLeftChannel(string serverUrl, string channelName);
}
+2
View File
@@ -3,6 +3,8 @@ namespace Decho.Services;
public interface ICryptoService
{
void MarkChannelEncrypted(string serverUrl, string channelName, bool isEncrypted);
bool HasChannelKey(string serverUrl, string channelName);
bool TryGetRoomKey(string serverUrl, string channelName, out byte[]? key);
}
@@ -86,7 +86,8 @@ public sealed class MessageComposerViewModel : ViewModelBase
IObservable<bool> canSend = this.WhenAnyValue(
x => x.Draft,
x => x.HasStagedFiles,
(draft, hasFiles) => !string.IsNullOrWhiteSpace(draft) || hasFiles);
(draft, hasFiles) =>
!string.IsNullOrWhiteSpace(draft) || hasFiles);
SendCommand = ReactiveCommand.Create(Send, canSend);
_ = this.WhenAnyValue(x => x.Draft).Subscribe(OnDraftChanged);
@@ -179,20 +180,7 @@ public sealed class MessageComposerViewModel : ViewModelBase
ReplyTarget = null;
}
private void UpdateStagedSummary()
{
this.RaisePropertyChanged(nameof(HasStagedFiles));
StagedFilesSummary = StagedFiles.Count > 0
? $"{StagedFiles.Count} file(s) staged"
: string.Empty;
}
private void OnDraftChanged(string? draft)
{
Autocomplete.Update(draft ?? string.Empty);
}
private void Send()
internal void Send()
{
string text = Draft.Trim();
Draft = string.Empty;
@@ -212,4 +200,17 @@ public sealed class MessageComposerViewModel : ViewModelBase
SendRequested?.Invoke(ServerUrl, text, filePaths, replyToId);
}
private void UpdateStagedSummary()
{
this.RaisePropertyChanged(nameof(HasStagedFiles));
StagedFilesSummary = StagedFiles.Count > 0
? $"{StagedFiles.Count} file(s) staged"
: string.Empty;
}
private void OnDraftChanged(string? draft)
{
Autocomplete.Update(draft ?? string.Empty);
}
}