mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-04 00:46:11 +02:00
Enable author profile dialog on author name click in message view
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
<TextBlock VerticalAlignment="Top"
|
||||
Text="{Binding AuthorName}"
|
||||
FontWeight="Bold"
|
||||
Foreground="{Binding AuthorColor}" />
|
||||
Foreground="{Binding AuthorColor}"
|
||||
Cursor="Hand"
|
||||
PointerPressed="OnAuthorNamePointerPressed" />
|
||||
<TextBlock VerticalAlignment="Top"
|
||||
Text="{Binding TimeText}"
|
||||
FontSize="10"
|
||||
|
||||
@@ -5,6 +5,8 @@ using Avalonia.Platform.Storage;
|
||||
|
||||
using Decho.ViewModels;
|
||||
|
||||
using EchoHub.Core.DTOs;
|
||||
|
||||
namespace Decho.Views;
|
||||
|
||||
public partial class MessageItemView : UserControl
|
||||
@@ -69,6 +71,35 @@ public partial class MessageItemView : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnAuthorNamePointerPressed(object? sender, Avalonia.Input.PointerPressedEventArgs e)
|
||||
{
|
||||
if (DataContext is not MessageViewModel msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TopLevel? topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel?.DataContext is not MainWindowViewModel mainVm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string serverUrl = msg.ServerUrl ?? mainVm.Chat.CurrentServerUrl;
|
||||
string username = msg.Model.Author.Id;
|
||||
UserProfileDto? profile = await mainVm.ConnectionService.GetUserProfileAsync(serverUrl, username);
|
||||
if (profile is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ProfileWindow dialog = new ProfileWindow(profile);
|
||||
|
||||
if (topLevel is Window parent)
|
||||
{
|
||||
await dialog.ShowDialog(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnDownloadClicked(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not MessageViewModel msg)
|
||||
|
||||
Reference in New Issue
Block a user