mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
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}`);
|
||||
|
||||
Reference in New Issue
Block a user