Erweiterungen

This commit is contained in:
2025-10-09 11:05:46 +02:00
parent 9b9a2feb6d
commit 01815ff084

View File

@@ -397,6 +397,7 @@ public class MessageDetailsView extends Main implements BeforeEnterObserver {
private void renderMessages(List<Message> messages) { private void renderMessages(List<Message> messages) {
LocalDate currentDate = null; LocalDate currentDate = null;
Div lastMessageWrapper = null;
for (Message message : messages) { for (Message message : messages) {
LocalDateTime timestamp = resolveTimestamp(message); LocalDateTime timestamp = resolveTimestamp(message);
LocalDate messageDate = timestamp.toLocalDate(); LocalDate messageDate = timestamp.toLocalDate();
@@ -407,12 +408,19 @@ public class MessageDetailsView extends Main implements BeforeEnterObserver {
String content = Optional.ofNullable(message.getContent()).orElse("(kein Inhalt)"); String content = Optional.ofNullable(message.getContent()).orElse("(kein Inhalt)");
if (message.getOrigin() == MessageOrigin.INCOMING) { if (message.getOrigin() == MessageOrigin.INCOMING) {
messagesContainer.add(createIncomingMessage(content, timestamp)); lastMessageWrapper = createIncomingMessage(content, timestamp);
messagesContainer.add(lastMessageWrapper);
} else { } else {
messagesContainer.add(createOutgoingMessage(content, timestamp)); lastMessageWrapper = createOutgoingMessage(content, timestamp);
messagesContainer.add(lastMessageWrapper);
} }
} }
// Remove margin-bottom from the last message to control spacing precisely
if (lastMessageWrapper != null) {
lastMessageWrapper.getStyle().set("margin-bottom", "5px");
}
ensureScrollAnchor(); ensureScrollAnchor();
scrollToBottom(); scrollToBottom();
@@ -449,17 +457,17 @@ public class MessageDetailsView extends Main implements BeforeEnterObserver {
"console.log('Scroll anchor found:', anchor);" + "console.log('Scroll anchor found:', anchor);" +
// First attempt after 50ms - instant scroll // First attempt after 50ms - instant scroll
"setTimeout(() => {" + "setTimeout(() => {" +
" anchor.scrollIntoView({ behavior: 'instant', block: 'end' });" + " anchor.scrollIntoView({ behavior: 'instant', block: 'nearest' });" +
" console.log('Scroll attempt 1: scrollIntoView called (instant)');" + " console.log('Scroll attempt 1: scrollIntoView called (instant)');" +
"}, 50);" + "}, 50);" +
// Second attempt after 200ms - instant scroll // Second attempt after 200ms - instant scroll
"setTimeout(() => {" + "setTimeout(() => {" +
" anchor.scrollIntoView({ behavior: 'instant', block: 'end' });" + " anchor.scrollIntoView({ behavior: 'instant', block: 'nearest' });" +
" console.log('Scroll attempt 2: scrollIntoView called (instant)');" + " console.log('Scroll attempt 2: scrollIntoView called (instant)');" +
"}, 200);" + "}, 200);" +
// Third attempt after 500ms - instant scroll // Third attempt after 500ms - instant scroll
"setTimeout(() => {" + "setTimeout(() => {" +
" anchor.scrollIntoView({ behavior: 'instant', block: 'end' });" + " anchor.scrollIntoView({ behavior: 'instant', block: 'nearest' });" +
" console.log('Scroll attempt 3: scrollIntoView called (instant)');" + " console.log('Scroll attempt 3: scrollIntoView called (instant)');" +
"}, 500);" "}, 500);"
); );