diff --git a/src/pages/channels/messaging/MessageArea.tsx b/src/pages/channels/messaging/MessageArea.tsx index 9753abcdc6821a0d1d4241a5ebcdf030b8aa0634..f69ae67800c077a5baad8e2c1b257a9b291af418 100644 --- a/src/pages/channels/messaging/MessageArea.tsx +++ b/src/pages/channels/messaging/MessageArea.tsx @@ -94,16 +94,6 @@ export function MessageArea({ id }: Props) { 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. @@ -153,40 +143,6 @@ export function MessageArea({ id }: Props) { } }, [ 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. // ? Also handle StayAtBottom useEffect(() => { diff --git a/src/pages/channels/messaging/MessageRenderer.tsx b/src/pages/channels/messaging/MessageRenderer.tsx index 1eae8e7e96ed4b6c389d5b591bf12f3f027f5109..6abbf466581b73f8193b62eb68fd44abc3812b69 100644 --- a/src/pages/channels/messaging/MessageRenderer.tsx +++ b/src/pages/channels/messaging/MessageRenderer.tsx @@ -1,5 +1,6 @@ import { decodeTime } from "ulid"; import { memo } from "preact/compat"; +import { defer } from "../../../lib/defer"; import MessageEditor from "./MessageEditor"; import { Children } from "../../../types/Preact"; import ConversationStart from "./ConversationStart"; @@ -15,6 +16,7 @@ import { AppContext } from "../../../context/revoltjs/RevoltClient"; import RequiresOnline from "../../../context/revoltjs/RequiresOnline"; import { internalSubscribe, internalEmit } from "../../../lib/eventEmitter"; import { SystemMessage } from "../../../components/common/messaging/SystemMessage"; +import { Users } from "revolt.js/dist/api/objects"; interface Props { id: string; @@ -89,6 +91,12 @@ function MessageRenderer({ id, state, queue }: Props) { 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) { if (previous) { compare( @@ -102,21 +110,30 @@ function MessageRenderer({ id, state, queue }: Props) { if (message.author === "00000000000000000000000000") { render.push(<SystemMessage key={message._id} message={message} attachContext />); } else { - render.push( - <Message message={message} - key={message._id} - head={head} - content={ - editing === message._id ? - <MessageEditor message={message} finish={stopEditing} /> - : undefined - } - attachContext /> - ); + // ! FIXME: temp solution + if (client.users.get(message.author)?.relationship === Users.Relationship.Blocked) { + blocked++; + } else { + if (blocked > 0) pushBlocked(); + + render.push( + <Message message={message} + key={message._id} + head={head} + content={ + editing === message._id ? + <MessageEditor message={message} finish={stopEditing} /> + : undefined + } + attachContext /> + ); + } } previous = message; } + + if (blocked > 0) pushBlocked(); const nonces = state.messages.map(x => x.nonce); if (state.atBottom) { diff --git a/src/pages/settings/GenericSettings.tsx b/src/pages/settings/GenericSettings.tsx index 5f11d615f4063cf33371230d6614534c21d9b58e..484ea683cf6861b03aeb11e53bd88e477e599995 100644 --- a/src/pages/settings/GenericSettings.tsx +++ b/src/pages/settings/GenericSettings.tsx @@ -62,7 +62,7 @@ export function GenericSettings({ pages, switchPage, category, custom, children, content={ isTouchscreenDevice ? theme["primary-header"] - : theme["background"] + : theme["secondary-background"] } /> </Helmet>