Messages
This commit is contained in:
+4
-3
@@ -165,17 +165,18 @@ export default class Enclave<P = Page> {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case "Messages":
|
case "Messages":
|
||||||
console.log("msg", msg.messages);
|
|
||||||
Object.entries(msg.messages).forEach(([channelId, messages]) => {
|
Object.entries(msg.messages).forEach(([channelId, messages]) => {
|
||||||
if (!server.messages[channelId]) {
|
if (!server.messages[channelId]) {
|
||||||
server.messages[channelId] = new Set();
|
server.messages[channelId] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.forEach((message) => {
|
messages.forEach((message) => {
|
||||||
server.messages[channelId].add(message);
|
server.messages[channelId][message.id] = message;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.forceRender();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ export default class EnclaveServer {
|
|||||||
public isSecure: boolean;
|
public isSecure: boolean;
|
||||||
public websocket?: EnclaveWebSocket;
|
public websocket?: EnclaveWebSocket;
|
||||||
public meta?: ServerMeta;
|
public meta?: ServerMeta;
|
||||||
public messages: Record<string, Set<StoredMessage>>;
|
public messages: Record<string, Record<string, StoredMessage>>;
|
||||||
|
|
||||||
public constructor(hostname: string, isSecure: boolean) {
|
public constructor(hostname: string, isSecure: boolean) {
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Enclave from "@/app/app";
|
import Enclave from "@/app/app";
|
||||||
import { ChannelPageProps } from "@/components/page/PageView";
|
import { ChannelPageProps } from "@/components/page/PageView";
|
||||||
|
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { StoredMessage } from "@/lib/types";
|
import { StoredMessage } from "@/lib/types";
|
||||||
@@ -40,8 +41,10 @@ export default function TextChannel({
|
|||||||
|
|
||||||
<div className="h-full flex flex-col gap-2.5 px-3 pt-4 overflow-y-scroll">
|
<div className="h-full flex flex-col gap-2.5 px-3 pt-4 overflow-y-scroll">
|
||||||
{appRef.current?.server?.messages[channel.id] &&
|
{appRef.current?.server?.messages[channel.id] &&
|
||||||
Array.from(appRef.current?.server?.messages[channel.id]).map(
|
Object.entries(appRef.current?.server?.messages[channel.id]).map(
|
||||||
(message) => <TextMessage appRef={appRef} message={message} />,
|
([_, message]) => (
|
||||||
|
<TextMessage key={message.id} appRef={appRef} message={message} />
|
||||||
|
),
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -79,9 +82,11 @@ export function TextMessage({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-lg flex gap-3 px-3 py-3 hover:bg-muted/40">
|
<div className="rounded-lg flex gap-3 px-3 py-3 hover:bg-muted/40">
|
||||||
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-muted-foreground">
|
<Avatar className="h-10 w-10">
|
||||||
|
<AvatarFallback>
|
||||||
{message.author.slice(0, 2).toUpperCase()}
|
{message.author.slice(0, 2).toUpperCase()}
|
||||||
</div>
|
</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-baseline gap-2">
|
<div className="flex items-baseline gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user