refac
This commit is contained in:
1 parent
2c804b0ac4
commit
7ea7680f56
4 files changed
+69
-31
No files matched your search
@@ -76,6 +76,27 @@
|
||||
);
|
||||
};
|
||||
|
||||
const pinHandler = (
|
||||
messageId: string,
|
||||
pinned: boolean,
|
||||
pinnedBy: string | null = pinned ? ($user?.id ?? null) : null,
|
||||
pinnedAt: number | null = pinned ? Date.now() * 1000000 : null
|
||||
) => {
|
||||
if (messages) {
|
||||
messages = messages.map((message) => {
|
||||
if (message.id === messageId) {
|
||||
return {
|
||||
...message,
|
||||
is_pinned: pinned,
|
||||
pinned_by: pinnedBy,
|
||||
pinned_at: pinnedAt
|
||||
};
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const initHandler = async () => {
|
||||
if (currentId) {
|
||||
updateLastReadAt(currentId);
|
||||
@@ -305,17 +326,7 @@
|
||||
<Pane defaultSize={50} minSize={50} class="h-full flex flex-col w-full relative">
|
||||
<Navbar
|
||||
{channel}
|
||||
onPin={(messageId, pinned) => {
|
||||
messages = messages.map((message) => {
|
||||
if (message.id === messageId) {
|
||||
return {
|
||||
...message,
|
||||
is_pinned: pinned
|
||||
};
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}}
|
||||
onPin={pinHandler}
|
||||
onUpdate={async () => {
|
||||
channel = await getChannelById(localStorage.token, id).catch((error) => {
|
||||
return null;
|
||||
@@ -347,6 +358,7 @@
|
||||
onThread={(id) => {
|
||||
threadId = id;
|
||||
}}
|
||||
onPin={pinHandler}
|
||||
onLoad={async () => {
|
||||
const newMessages = await getChannelMessages(
|
||||
localStorage.token,
|
||||
@@ -406,6 +418,7 @@
|
||||
<Thread
|
||||
{threadId}
|
||||
{channel}
|
||||
onPin={pinHandler}
|
||||
onClose={() => {
|
||||
threadId = null;
|
||||
}}
|
||||
@@ -428,6 +441,7 @@
|
||||
<Thread
|
||||
{threadId}
|
||||
{channel}
|
||||
onPin={pinHandler}
|
||||
onClose={() => {
|
||||
threadId = null;
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user