Temporary blocked messages solution.

Fix settings theme colour.
This commit is contained in:
Paul 2021-07-03 14:45:08 +01:00
parent a4ac87f24d
commit 324b87b9b5
3 changed files with 29 additions and 56 deletions

View file

@ -94,16 +94,6 @@ export function MessageArea({ id }: Props) {
setScrollState({ type: "Free" }); setScrollState({ type: "Free" });
} }
}); });
/*if (v.type === 'StayAtBottom') {
if (scrollState.current.type === 'Bottom' || atBottom()) {
scrollState.current = { type: 'ScrollToBottom', smooth: v.smooth };
} else {
scrollState.current = { type: 'Free' };
}
} else {
scrollState.current = v;
}*/
} }
// ? Determine if we are at the bottom of the scroll container. // ? Determine if we are at the bottom of the scroll container.
@ -153,40 +143,6 @@ export function MessageArea({ id }: Props) {
} }
}, [ status, state ]); }, [ status, state ]);
// ? Scroll to the bottom before the browser paints.
useLayoutEffect(() => {
// ! FIXME: NO REACTIVITY
if (scrollState.current.type === "ScrollToBottom") {
setScrollState({ type: "Bottom", scrollingUntil: + new Date() + 150 });
animateScroll.scrollToBottom({
container: ref.current,
duration: scrollState.current.smooth ? 150 : 0
});
} else if (scrollState.current.type === "OffsetTop") {
animateScroll.scrollTo(
Math.max(
101,
ref.current.scrollTop +
(ref.current.scrollHeight - scrollState.current.previousHeight)
),
{
container: ref.current,
duration: 0
}
);
setScrollState({ type: "Free" });
} else if (scrollState.current.type === "ScrollTop") {
animateScroll.scrollTo(scrollState.current.y, {
container: ref.current,
duration: 0
});
setScrollState({ type: "Free" });
}
}, [scrollState]);
// ? When the container is scrolled. // ? When the container is scrolled.
// ? Also handle StayAtBottom // ? Also handle StayAtBottom
useEffect(() => { useEffect(() => {

View file

@ -1,5 +1,6 @@
import { decodeTime } from "ulid"; import { decodeTime } from "ulid";
import { memo } from "preact/compat"; import { memo } from "preact/compat";
import { defer } from "../../../lib/defer";
import MessageEditor from "./MessageEditor"; import MessageEditor from "./MessageEditor";
import { Children } from "../../../types/Preact"; import { Children } from "../../../types/Preact";
import ConversationStart from "./ConversationStart"; import ConversationStart from "./ConversationStart";
@ -15,6 +16,7 @@ import { AppContext } from "../../../context/revoltjs/RevoltClient";
import RequiresOnline from "../../../context/revoltjs/RequiresOnline"; import RequiresOnline from "../../../context/revoltjs/RequiresOnline";
import { internalSubscribe, internalEmit } from "../../../lib/eventEmitter"; import { internalSubscribe, internalEmit } from "../../../lib/eventEmitter";
import { SystemMessage } from "../../../components/common/messaging/SystemMessage"; import { SystemMessage } from "../../../components/common/messaging/SystemMessage";
import { Users } from "revolt.js/dist/api/objects";
interface Props { interface Props {
id: string; id: string;
@ -89,6 +91,12 @@ function MessageRenderer({ id, state, queue }: Props) {
head = curAuthor !== prevAuthor || Math.abs(btime - atime) >= 420000; head = curAuthor !== prevAuthor || Math.abs(btime - atime) >= 420000;
} }
let blocked = 0;
function pushBlocked() {
render.push(<span>{ blocked } blocked messages</span>);
blocked = 0;
}
for (const message of state.messages) { for (const message of state.messages) {
if (previous) { if (previous) {
compare( compare(
@ -102,22 +110,31 @@ function MessageRenderer({ id, state, queue }: Props) {
if (message.author === "00000000000000000000000000") { if (message.author === "00000000000000000000000000") {
render.push(<SystemMessage key={message._id} message={message} attachContext />); render.push(<SystemMessage key={message._id} message={message} attachContext />);
} else { } else {
render.push( // ! FIXME: temp solution
<Message message={message} if (client.users.get(message.author)?.relationship === Users.Relationship.Blocked) {
key={message._id} blocked++;
head={head} } else {
content={ if (blocked > 0) pushBlocked();
editing === message._id ?
<MessageEditor message={message} finish={stopEditing} /> render.push(
: undefined <Message message={message}
} key={message._id}
attachContext /> head={head}
); content={
editing === message._id ?
<MessageEditor message={message} finish={stopEditing} />
: undefined
}
attachContext />
);
}
} }
previous = message; previous = message;
} }
if (blocked > 0) pushBlocked();
const nonces = state.messages.map(x => x.nonce); const nonces = state.messages.map(x => x.nonce);
if (state.atBottom) { if (state.atBottom) {
for (const msg of queue) { for (const msg of queue) {

View file

@ -62,7 +62,7 @@ export function GenericSettings({ pages, switchPage, category, custom, children,
content={ content={
isTouchscreenDevice isTouchscreenDevice
? theme["primary-header"] ? theme["primary-header"]
: theme["background"] : theme["secondary-background"]
} }
/> />
</Helmet> </Helmet>