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,20 +1,17 @@
import { Prompt } from "react-router";
import { useHistory } from "react-router-dom";
import {
Attachment,
Channels,
EmbedImage,
Servers,
Users,
} from "revolt.js/dist/api/objects";
import type { Attachment } from "revolt-api/types/Autumn";
import type { EmbedImage } from "revolt-api/types/January";
import { Channel } from "revolt.js/dist/maps/Channels";
import { Message } from "revolt.js/dist/maps/Messages";
import { Server } from "revolt.js/dist/maps/Servers";
import { User } from "revolt.js/dist/maps/Users";
import { createContext } from "preact";
import { useContext, useEffect, useMemo, useState } from "preact/hooks";
import { internalSubscribe } from "../../lib/eventEmitter";
import { Channel, Server, User } from "../../mobx";
import { Action } from "../../components/ui/Modal";
import { Children } from "../../types/Preact";
@@ -39,7 +36,7 @@ export type Screen =
| { type: "leave_server"; target: Server }
| { type: "delete_server"; target: Server }
| { type: "delete_channel"; target: Channel }
| { type: "delete_message"; target: Channels.Message }
| { type: "delete_message"; target: Message }
| {
type: "create_invite";
target: Channel;

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;
}