From 406fa67d78489912819ec015dcc1690e3e8d4b41 Mon Sep 17 00:00:00 2001
From: Emilia <emilia@jumpsca.re>
Date: Mon, 3 Mar 2025 17:32:02 +0200
Subject: [PATCH] Reply preview

---
 Blacklight/TODO                                   | 11 ++++++++++-
 .../ViewModels/Documents/DocumentViewModel.cs     | 15 ++++++++++++++-
 Blacklight/Views/Documents/DocumentView.axaml     | 14 ++++++++++++--
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/Blacklight/TODO b/Blacklight/TODO
index acd44ea..f12f8a6 100644
--- a/Blacklight/TODO
+++ b/Blacklight/TODO
@@ -21,4 +21,13 @@ Message editing (scary)
 Maybe look into transforming fakeMsg into final message instead of remove and then wait for event to arrive,
 or remove it when the event has arrived (how to tell? -> Client attribute with guid?)
 
-Show avatars for people
\ No newline at end of file
+Show avatars for people
+
+Channel making
+
+Quark joining
+
+Quark making
+
+layout saving
+
diff --git a/Blacklight/ViewModels/Documents/DocumentViewModel.cs b/Blacklight/ViewModels/Documents/DocumentViewModel.cs
index c3c933a..f00b34e 100644
--- a/Blacklight/ViewModels/Documents/DocumentViewModel.cs
+++ b/Blacklight/ViewModels/Documents/DocumentViewModel.cs
@@ -113,14 +113,26 @@ public class DocumentViewModel : Document
         get => _replyToId;
         set
         {
-            if (SetProperty(ref _replyToId, value)) OnPropertyChanged(nameof(IsReplying));
+            if (SetProperty(ref _replyToId, value))
+            {
+                OnPropertyChanged(nameof(IsReplying));
+                OnPropertyChanged(nameof(ReplyToMessage));
+            }
         }
     }
 
+    public Message? ReplyToMessage => Messages.FirstOrDefault(m => m.Id == ReplyToId);
+
     public bool IsReplying => ReplyToId != null;
     
     public FontStyle FontStyle => IsEphemeral ? FontStyle.Italic : FontStyle.Normal;
     public ICommand SendCommand => new RelayCommand(SendMessage);
+    public ICommand UnReplyCommand => new RelayCommand(UnReply);
+
+    private void UnReply()
+    {
+        ReplyToId = null;
+    }
 
     public void ReplyMessage(object obj)
     {
@@ -197,5 +209,6 @@ public class DocumentViewModel : Document
             Log.Error(ex, "Failed to send message");
         }
         MessageInput = "";
+        ReplyToId = null;
     }
 }
\ No newline at end of file
diff --git a/Blacklight/Views/Documents/DocumentView.axaml b/Blacklight/Views/Documents/DocumentView.axaml
index 59ebe2a..ff57516 100644
--- a/Blacklight/Views/Documents/DocumentView.axaml
+++ b/Blacklight/Views/Documents/DocumentView.axaml
@@ -78,12 +78,22 @@
 				<ColumnDefinition Width="*" />
 				<ColumnDefinition Width="Auto" />
 			</Grid.ColumnDefinitions>
-			<TextBox MaxHeight="200" Grid.Column="0" AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding MessageInput}">
+			<Grid.RowDefinitions>
+				<RowDefinition Height="*" />
+				<RowDefinition Height="Auto" />
+			</Grid.RowDefinitions>
+			<StackPanel IsVisible="{Binding IsReplying}" Orientation="Horizontal" Grid.ColumnSpan="2" Grid.Row="0">
+				<PathIcon Foreground="Gray" Margin="0 0 1 0" VerticalAlignment="Center" Height="10" Width="10" Data="{StaticResource ReplyIcon}"></PathIcon>
+				<TextBlock VerticalAlignment="Center" FontWeight="Bold" Foreground="Gray" Text="{Binding ReplyToMessage.VisualAuthor.Username}" Margin="0 0 2 0" />
+				<TextBlock VerticalAlignment="Center" Foreground="Gray" Text="{Binding ReplyToMessage.Content}"></TextBlock>
+				<Button Command="{Binding UnReplyCommand}">Cancel reply</Button>
+			</StackPanel>
+			<TextBox Grid.Row="1" MaxHeight="200" Grid.Column="0" AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding MessageInput}">
 				<TextBox.KeyBindings>
 					<KeyBinding Gesture="Enter" Command="{Binding SendCommand}" />
 				</TextBox.KeyBindings>
 			</TextBox>
-			<Button Grid.Column="1" Command="{Binding SendCommand}">Send</Button>
+			<Button Grid.Row="1" Grid.Column="1" Command="{Binding SendCommand}">Send</Button>
 		</Grid>
 	</Grid>
 	<!-- </Grid> -->
-- 
GitLab