Enable author profile dialog on author name click in message view

This commit is contained in:
Stone_Red
2026-07-16 01:10:11 +02:00
parent 39c7fe4f48
commit a1c0e299d3
2 changed files with 34 additions and 1 deletions
+3 -1
View File
@@ -15,7 +15,9 @@
<TextBlock VerticalAlignment="Top" <TextBlock VerticalAlignment="Top"
Text="{Binding AuthorName}" Text="{Binding AuthorName}"
FontWeight="Bold" FontWeight="Bold"
Foreground="{Binding AuthorColor}" /> Foreground="{Binding AuthorColor}"
Cursor="Hand"
PointerPressed="OnAuthorNamePointerPressed" />
<TextBlock VerticalAlignment="Top" <TextBlock VerticalAlignment="Top"
Text="{Binding TimeText}" Text="{Binding TimeText}"
FontSize="10" FontSize="10"
+31
View File
@@ -5,6 +5,8 @@ using Avalonia.Platform.Storage;
using Decho.ViewModels; using Decho.ViewModels;
using EchoHub.Core.DTOs;
namespace Decho.Views; namespace Decho.Views;
public partial class MessageItemView : UserControl 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) private async void OnDownloadClicked(object? sender, RoutedEventArgs e)
{ {
if (DataContext is not MessageViewModel msg) if (DataContext is not MessageViewModel msg)