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
+1 -1
View File
@@ -78,4 +78,4 @@ public partial class App : Application
Locator.Current.GetService<CommandHandler>()!,
Locator.Current.GetService<NotificationSoundService>()!));
}
}
}
+1 -1
View File
@@ -97,4 +97,4 @@ internal sealed class AttachmentService : IAttachmentService
return null;
}
}
}
}
+1 -1
View File
@@ -341,4 +341,4 @@ internal sealed class ChannelService : IChannelService
attachments,
dto.ReplyTo);
}
}
}
@@ -68,4 +68,4 @@ internal sealed class ConfigPersistenceService : IConfigPersistenceService
action(config, saved);
ConfigManager.Save(config);
}
}
}
+10 -1
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);
@@ -358,4 +367,4 @@ public sealed class ConnectionService : IConnectionService
ServerStateChanged?.Invoke(entry.Server);
};
}
}
}
+1 -1
View File
@@ -11,4 +11,4 @@ internal sealed class ConnectionStore : IConnectionStore
public ServerConnection? Get(string serverUrl)
=> _connections.TryGetValue(serverUrl, out ServerConnection? entry) ? entry : null;
}
}
+1 -1
View File
@@ -37,4 +37,4 @@ internal sealed class CryptoService : ICryptoService
return entry.Manager.RoomKeys.TryGetKey(channelName, out key);
}
}
}
+2 -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);
}
}
+1 -1
View File
@@ -3,4 +3,4 @@ namespace Decho.Services;
internal interface IConnectionStore
{
ServerConnection? Get(string serverUrl);
}
}
+3 -1
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);
}
}
+1 -1
View File
@@ -9,4 +9,4 @@ public interface IInviteService
Task<List<InviteDto>> GetInvitesAsync(string serverUrl);
Task RevokeInviteAsync(string serverUrl, string code);
}
}
+1 -1
View File
@@ -34,4 +34,4 @@ public interface IUserService
Task<string> ExportMyDataAsync(string serverUrl);
string? GetRefreshToken(string serverUrl);
}
}
+1 -1
View File
@@ -34,4 +34,4 @@ internal sealed class InviteService : IInviteService
await entry.ApiClient.RevokeInviteAsync(code);
}
}
}
+1 -1
View File
@@ -18,4 +18,4 @@ internal sealed class ServerConnection
Server = server;
User = user;
}
}
}
+1 -1
View File
@@ -1276,4 +1276,4 @@ public sealed class MainWindowViewModel : ViewModelBase
{
return Chat.CurrentServerUrl;
}
}
}
@@ -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);
}
}