forked from abner/for-legacy-web
Remove remaining references to useUser(s).
Add Channel object.
This commit is contained in:
@@ -9,11 +9,6 @@ import {
|
||||
ClientStatus,
|
||||
StatusContext,
|
||||
} from "../context/revoltjs/RevoltClient";
|
||||
import {
|
||||
useChannels,
|
||||
useForceUpdate,
|
||||
useUser,
|
||||
} from "../context/revoltjs/hooks";
|
||||
|
||||
import Header from "../components/ui/Header";
|
||||
|
||||
@@ -32,13 +27,9 @@ export default function Open() {
|
||||
);
|
||||
}
|
||||
|
||||
const ctx = useForceUpdate();
|
||||
const channels = useChannels(undefined, ctx);
|
||||
const user = useUser(id, ctx);
|
||||
|
||||
useEffect(() => {
|
||||
if (id === "saved") {
|
||||
for (const channel of channels) {
|
||||
for (const channel of client.channels.toArray()) {
|
||||
if (channel?.channel_type === "SavedMessages") {
|
||||
history.push(`/channel/${channel._id}`);
|
||||
return;
|
||||
@@ -53,12 +44,15 @@ export default function Open() {
|
||||
return;
|
||||
}
|
||||
|
||||
let user = client.users.get(id);
|
||||
if (user) {
|
||||
const channel: string | undefined = channels.find(
|
||||
(channel) =>
|
||||
channel?.channel_type === "DirectMessage" &&
|
||||
channel.recipients.includes(id),
|
||||
)?._id;
|
||||
const channel: string | undefined = client.channels
|
||||
.toArray()
|
||||
.find(
|
||||
(channel) =>
|
||||
channel?.channel_type === "DirectMessage" &&
|
||||
channel.recipients.includes(id),
|
||||
)?._id;
|
||||
|
||||
if (channel) {
|
||||
history.push(`/channel/${channel}`);
|
||||
|
||||
@@ -9,11 +9,7 @@ import { useEffect, useState } from "preact/hooks";
|
||||
import { useData } from "../../../mobx/State";
|
||||
|
||||
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||
import {
|
||||
useChannels,
|
||||
useForceUpdate,
|
||||
useUsers,
|
||||
} from "../../../context/revoltjs/hooks";
|
||||
import { useChannels, useForceUpdate } from "../../../context/revoltjs/hooks";
|
||||
import { getChannelName } from "../../../context/revoltjs/util";
|
||||
|
||||
import UserIcon from "../../../components/common/user/UserIcon";
|
||||
@@ -34,7 +30,6 @@ export const Invites = observer(({ server }: Props) => {
|
||||
const channels = useChannels(invites?.map((x) => x.channel) ?? [], ctx);
|
||||
|
||||
const store = useData();
|
||||
const client = useClient();
|
||||
const users = invites?.map((invite) => store.users.get(invite.creator));
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -10,7 +10,6 @@ import { useEffect, useState } from "preact/hooks";
|
||||
import { useData } from "../../../mobx/State";
|
||||
|
||||
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||
import { useForceUpdate, useUsers } from "../../../context/revoltjs/hooks";
|
||||
|
||||
import UserIcon from "../../../components/common/user/UserIcon";
|
||||
import Button from "../../../components/ui/Button";
|
||||
|
||||
Reference in New Issue
Block a user