mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-04 08:56:14 +02:00
Code cleanup
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user