further optimize message rendering

This commit is contained in:
hippoz 2022-09-17 23:44:46 +03:00
parent 595b6ac1f2
commit 80ab321103
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 4 additions and 4 deletions

View file

@ -84,9 +84,9 @@
<div class="messages-container" on:scroll={ onScroll } bind:this={ scrollTarget }>
{#each $messages as message (message.id)}
{#if message._showDateMarkerAbove}
{#if message._aboveDateMarker}
<div class="time-separator">
<span>{ new Intl.DateTimeFormat(getItem("ui:locale"), { month: "long", day: "numeric", year: "numeric" }).format(message._createdAtDate) }</span>
<span>{ message._aboveDateMarker }</span>
</div>
{/if}
<Message message={message} />

View file

@ -152,7 +152,7 @@ class MessageStore extends Store {
message._mentions = false;
message._editable = false;
message._clumped = false;
message._showDateMarkerAbove = false;
message._aboveDateMarker = null;
if (userInfoStore.value && message.content.includes("@" + userInfoStore.value.username)) {
message._mentions = true;
}
@ -163,7 +163,7 @@ class MessageStore extends Store {
message._clumped = true;
}
if (previous && (previous._createdAtDateString !== message._createdAtDateString)) {
message._showDateMarkerAbove = true;
message._aboveDateMarker = new Intl.DateTimeFormat(getItem("ui:locale"), { month: "long", day: "numeric", year: "numeric" }).format(message._createdAtDate);
}
return message;
}