mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-04 00:46:11 +02:00
Code cleanup
This commit is contained in:
@@ -78,4 +78,4 @@ public partial class App : Application
|
||||
Locator.Current.GetService<CommandHandler>()!,
|
||||
Locator.Current.GetService<NotificationSoundService>()!));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,4 +97,4 @@ internal sealed class AttachmentService : IAttachmentService
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,4 @@ internal sealed class ConnectionStore : IConnectionStore
|
||||
|
||||
public ServerConnection? Get(string serverUrl)
|
||||
=> _connections.TryGetValue(serverUrl, out ServerConnection? entry) ? entry : null;
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,4 @@ internal sealed class CryptoService : ICryptoService
|
||||
|
||||
return entry.Manager.RoomKeys.TryGetKey(channelName, out key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@ namespace Decho.Services;
|
||||
internal interface IConnectionStore
|
||||
{
|
||||
ServerConnection? Get(string serverUrl);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,4 @@ public interface IInviteService
|
||||
Task<List<InviteDto>> GetInvitesAsync(string serverUrl);
|
||||
|
||||
Task RevokeInviteAsync(string serverUrl, string code);
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,4 @@ public interface IUserService
|
||||
Task<string> ExportMyDataAsync(string serverUrl);
|
||||
|
||||
string? GetRefreshToken(string serverUrl);
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,4 @@ internal sealed class InviteService : IInviteService
|
||||
|
||||
await entry.ApiClient.RevokeInviteAsync(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,4 @@ internal sealed class ServerConnection
|
||||
Server = server;
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user