Start migration to revolt.js@5.0.0.

200 error milestone
This commit is contained in:
Paul
2021-07-30 20:24:53 +01:00
parent 564c1d8494
commit 3184269ba4
32 changed files with 215 additions and 834 deletions

View File

@@ -1,10 +1,8 @@
import { Client } from "revolt.js";
import { Message } from "revolt.js/dist/api/objects";
import { Channel } from "revolt.js/dist/maps/Channels";
import { Text } from "preact-i18n";
import { Channel } from "../../mobx";
import { Children } from "../../types/Preact";
export function takeError(error: any): string {
@@ -25,7 +23,6 @@ export function takeError(error: any): string {
}
export function getChannelName(
client: Client,
channel: Channel,
prefixType?: boolean,
): Children {
@@ -33,11 +30,10 @@ export function getChannelName(
return <Text id="app.navigation.tabs.saved" />;
if (channel.channel_type === "DirectMessage") {
const uid = client.channels.getRecipient(channel._id);
return (
<>
{prefixType && "@"}
{client.users.get(uid)?.username}
{channel.recipient!.username}
</>
);
}
@@ -48,12 +44,3 @@ export function getChannelName(
return <>{channel.name}</>;
}
export type MessageObject = Omit<Message, "edited"> & { edited?: string };
export function mapMessage(message: Partial<Message>) {
const { edited, ...msg } = message;
return {
...msg,
edited: edited?.$date,
} as MessageObject;
}