forked from abner/for-legacy-web
merge: branch 'quark/permissions'
This commit is contained in:
@@ -3,7 +3,7 @@ import { Ghost } from "@styled-icons/boxicons-solid";
|
||||
import { reaction } from "mobx";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Redirect, useParams } from "react-router-dom";
|
||||
import { Channel as ChannelI } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel as ChannelI } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
@@ -97,29 +97,35 @@ const PlaceholderBase = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
export function Channel({ id, server_id }: { id: string; server_id: string }) {
|
||||
const client = useClient();
|
||||
const channel = client.channels.get(id);
|
||||
export const Channel = observer(
|
||||
({ id, server_id }: { id: string; server_id: string }) => {
|
||||
const client = useClient();
|
||||
|
||||
if (server_id && !channel) {
|
||||
const server = client.servers.get(server_id);
|
||||
if (server && server.channel_ids.length > 0) {
|
||||
return (
|
||||
<Redirect
|
||||
to={`/server/${server_id}/channel/${server.channel_ids[0]}`}
|
||||
/>
|
||||
);
|
||||
if (!client.channels.exists(id)) {
|
||||
if (server_id) {
|
||||
const server = client.servers.get(server_id);
|
||||
if (server && server.channel_ids.length > 0) {
|
||||
return (
|
||||
<Redirect
|
||||
to={`/server/${server_id}/channel/${server.channel_ids[0]}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return <Redirect to="/" />;
|
||||
}
|
||||
|
||||
return <ChannelPlaceholder />;
|
||||
}
|
||||
}
|
||||
|
||||
if (!channel) return <ChannelPlaceholder />;
|
||||
const channel = client.channels.get(id)!;
|
||||
if (channel.channel_type === "VoiceChannel") {
|
||||
return <VoiceChannel channel={channel} />;
|
||||
}
|
||||
|
||||
if (channel.channel_type === "VoiceChannel") {
|
||||
return <VoiceChannel channel={channel} />;
|
||||
}
|
||||
|
||||
return <TextChannel channel={channel} />;
|
||||
}
|
||||
return <TextChannel channel={channel} />;
|
||||
},
|
||||
);
|
||||
|
||||
const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||
const layout = useApplicationState().layout;
|
||||
@@ -143,9 +149,9 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||
// Mark channel as read.
|
||||
useEffect(() => {
|
||||
setLastId(
|
||||
channel.unread
|
||||
(channel.unread
|
||||
? channel.client.unreads?.getUnread(channel._id)?.last_id
|
||||
: undefined ?? undefined,
|
||||
: undefined) ?? undefined,
|
||||
);
|
||||
|
||||
const checkUnread = () =>
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
} from "@styled-icons/boxicons-regular";
|
||||
import { Notepad, Group } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { Channel } from "revolt.js";
|
||||
import { User } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -2,7 +2,7 @@ import { runInAction } from "mobx";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useHistory, useParams } from "react-router-dom";
|
||||
import { animateScroll } from "react-scroll";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
import useResizeObserver from "use-resize-observer";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Message } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
import { X } from "@styled-icons/boxicons-regular";
|
||||
import isEqual from "lodash.isequal";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Masquerade } from "revolt-api/types/Channels";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { Message as MessageI } from "revolt.js/dist/maps/Messages";
|
||||
import { Nullable } from "revolt.js/dist/util/null";
|
||||
import { API } from "revolt.js";
|
||||
import { Message as MessageI } from "revolt.js";
|
||||
import { Nullable } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
import { decodeTime } from "ulid";
|
||||
|
||||
@@ -99,10 +98,10 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
||||
function compare(
|
||||
current: string,
|
||||
curAuthor: string,
|
||||
currentMasq: Nullable<Masquerade>,
|
||||
currentMasq: Nullable<API.Masquerade>,
|
||||
previous: string,
|
||||
prevAuthor: string,
|
||||
previousMasq: Nullable<Masquerade>,
|
||||
previousMasq: Nullable<API.Masquerade>,
|
||||
) {
|
||||
head = false;
|
||||
const atime = decodeTime(current),
|
||||
@@ -172,9 +171,7 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
||||
highlight={highlight === message._id}
|
||||
/>,
|
||||
);
|
||||
} else if (
|
||||
message.author?.relationship === RelationshipStatus.Blocked
|
||||
) {
|
||||
} else if (message.author?.relationship === "Blocked") {
|
||||
blocked++;
|
||||
} else {
|
||||
if (blocked > 0) pushBlocked();
|
||||
|
||||
Reference in New Issue
Block a user