mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-09 16:53:36 -05:00
Temporary blocked messages solution.
Fix settings theme colour.
This commit is contained in:
parent
a4ac87f24d
commit
324b87b9b5
3 changed files with 29 additions and 56 deletions
|
@ -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(() => {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -62,7 +62,7 @@ export function GenericSettings({ pages, switchPage, category, custom, children,
|
|||
content={
|
||||
isTouchscreenDevice
|
||||
? theme["primary-header"]
|
||||
: theme["background"]
|
||||
: theme["secondary-background"]
|
||||
}
|
||||
/>
|
||||
</Helmet>
|
||||
|
|
Loading…
Reference in a new issue