mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
100 error milestone.
Remove hooks completely. :)
This commit is contained in:
@@ -3,8 +3,6 @@ import styled from "styled-components";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
import { useData } from "../../../mobx/State";
|
||||
|
||||
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||
import { getChannelName } from "../../../context/revoltjs/util";
|
||||
|
||||
@@ -28,14 +26,13 @@ interface Props {
|
||||
}
|
||||
|
||||
export default observer(({ id }: Props) => {
|
||||
const store = useData();
|
||||
const client = useClient();
|
||||
const channel = store.channels.get(id);
|
||||
const channel = client.channels.get(id);
|
||||
if (!channel) return null;
|
||||
|
||||
return (
|
||||
<StartBase>
|
||||
<h1>{getChannelName(client, channel, true)}</h1>
|
||||
<h1>{getChannelName(channel, true)}</h1>
|
||||
<h4>
|
||||
<Text id="app.main.channel.start.group" />
|
||||
</h4>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
useIntermediate,
|
||||
} from "../../../context/intermediate/Intermediate";
|
||||
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||
import { MessageObject } from "../../../context/revoltjs/util";
|
||||
|
||||
import AutoComplete, {
|
||||
useAutoComplete,
|
||||
@@ -44,7 +44,7 @@ const EditorBase = styled.div`
|
||||
`;
|
||||
|
||||
interface Props {
|
||||
message: MessageObject;
|
||||
message: Message;
|
||||
finish: () => void;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ export default function MessageEditor({ message, finish }: Props) {
|
||||
const [content, setContent] = useState((message.content as string) ?? "");
|
||||
const { focusTaken } = useContext(IntermediateContext);
|
||||
const { openScreen } = useIntermediate();
|
||||
const client = useContext(AppContext);
|
||||
|
||||
async function save() {
|
||||
finish();
|
||||
@@ -60,13 +59,11 @@ export default function MessageEditor({ message, finish }: Props) {
|
||||
if (content.length === 0) {
|
||||
openScreen({
|
||||
id: "special_prompt",
|
||||
// @ts-expect-error
|
||||
type: "delete_message",
|
||||
// @ts-expect-error
|
||||
target: message,
|
||||
});
|
||||
} else if (content !== message.content) {
|
||||
await client.channels.editMessage(message.channel, message._id, {
|
||||
await message.editMessage({
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { X } from "@styled-icons/boxicons-regular";
|
||||
import { Users } from "revolt.js/dist/api/objects";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { SYSTEM_USER_ID } from "revolt.js";
|
||||
import { Message as MessageObject } from "revolt.js/dist/maps/Messages";
|
||||
import styled from "styled-components";
|
||||
import { decodeTime } from "ulid";
|
||||
|
||||
@@ -15,7 +17,6 @@ import { QueuedMessage } from "../../../redux/reducers/queue";
|
||||
|
||||
import RequiresOnline from "../../../context/revoltjs/RequiresOnline";
|
||||
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||
import { MessageObject } from "../../../context/revoltjs/util";
|
||||
|
||||
import Message from "../../../components/common/messaging/Message";
|
||||
import { SystemMessage } from "../../../components/common/messaging/SystemMessage";
|
||||
@@ -60,7 +61,7 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
function editLast() {
|
||||
if (state.type !== "RENDER") return;
|
||||
for (let i = state.messages.length - 1; i >= 0; i--) {
|
||||
if (state.messages[i].author === userId) {
|
||||
if (state.messages[i].author_id === userId) {
|
||||
setEditing(state.messages[i]._id);
|
||||
internalEmit("MessageArea", "jump_to_bottom");
|
||||
return;
|
||||
@@ -129,10 +130,15 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
|
||||
for (const message of state.messages) {
|
||||
if (previous) {
|
||||
compare(message._id, message.author, previous._id, previous.author);
|
||||
compare(
|
||||
message._id,
|
||||
message.author_id,
|
||||
previous._id,
|
||||
previous.author_id,
|
||||
);
|
||||
}
|
||||
|
||||
if (message.author === "00000000000000000000000000") {
|
||||
if (message.author_id === SYSTEM_USER_ID) {
|
||||
render.push(
|
||||
<SystemMessage
|
||||
key={message._id}
|
||||
@@ -143,10 +149,7 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
);
|
||||
} else {
|
||||
// ! FIXME: temp solution
|
||||
if (
|
||||
client.users.get(message.author)?.relationship ===
|
||||
Users.Relationship.Blocked
|
||||
) {
|
||||
if (message.author?.relationship === RelationshipStatus.Blocked) {
|
||||
blocked++;
|
||||
} else {
|
||||
if (blocked > 0) pushBlocked();
|
||||
@@ -183,7 +186,7 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
if (nonces.includes(msg.id)) continue;
|
||||
|
||||
if (previous) {
|
||||
compare(msg.id, userId!, previous._id, previous.author);
|
||||
compare(msg.id, userId!, previous._id, previous.author_id);
|
||||
|
||||
previous = {
|
||||
_id: msg.id,
|
||||
@@ -191,7 +194,8 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
} as any;
|
||||
}
|
||||
|
||||
render.push(
|
||||
// ! FIXME: add queued messages back
|
||||
/* render.push(
|
||||
<Message
|
||||
message={{
|
||||
...msg.data,
|
||||
@@ -202,7 +206,7 @@ function MessageRenderer({ id, state, queue, highlight }: Props) {
|
||||
head={head}
|
||||
attachContext
|
||||
/>,
|
||||
);
|
||||
); */
|
||||
}
|
||||
} else {
|
||||
render.push(
|
||||
|
||||
Reference in New Issue
Block a user