mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-09 02:05:28 +00:00
Temporary blocked messages solution.
Fix settings theme colour.
This commit is contained in:
@@ -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(() => {
|
||||||
|
|||||||
@@ -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,6 +110,12 @@ 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 {
|
||||||
|
// ! FIXME: temp solution
|
||||||
|
if (client.users.get(message.author)?.relationship === Users.Relationship.Blocked) {
|
||||||
|
blocked++;
|
||||||
|
} else {
|
||||||
|
if (blocked > 0) pushBlocked();
|
||||||
|
|
||||||
render.push(
|
render.push(
|
||||||
<Message message={message}
|
<Message message={message}
|
||||||
key={message._id}
|
key={message._id}
|
||||||
@@ -114,10 +128,13 @@ function MessageRenderer({ id, state, queue }: Props) {
|
|||||||
attachContext />
|
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) {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user