chore: delete intermediate

This commit is contained in:
Paul Makles
2022-07-05 21:13:42 +01:00
parent f7ff7d0dfe
commit f9c6f5cd9d
35 changed files with 129 additions and 1104 deletions

View File

@@ -7,8 +7,6 @@ import { useEffect, useState } from "preact/hooks";
import ContextMenus from "../lib/ContextMenus";
import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
import Popovers from "../context/intermediate/Popovers";
import { Titlebar } from "../components/native/Titlebar";
import BottomNavigation from "../components/navigation/BottomNavigation";
import LeftSidebar from "../components/navigation/LeftSidebar";
@@ -225,7 +223,6 @@ export default function App() {
</Switch>
</Routes>
<ContextMenus />
<Popovers />
</OverlappingPanels>
</AppContainer>
</>

View File

@@ -21,8 +21,6 @@ import { voiceState, VoiceStatus } from "../../../lib/vortex/VoiceState";
import { useApplicationState } from "../../../mobx/State";
import { SIDEBAR_MEMBERS } from "../../../mobx/stores/Layout";
import { useIntermediate } from "../../../context/intermediate/Intermediate";
import UpdateIndicator from "../../../components/common/UpdateIndicator";
import { modalController } from "../../../controllers/modals/ModalController";
import { ChannelHeaderProps } from "../ChannelHeader";
@@ -74,7 +72,6 @@ const SearchBar = styled.div`
export default function HeaderActions({ channel }: ChannelHeaderProps) {
const layout = useApplicationState().layout;
const { openScreen } = useIntermediate();
const history = useHistory();
function slideOpen() {

View File

@@ -23,10 +23,9 @@ import { internalEmit, internalSubscribe } from "../../../lib/eventEmitter";
import { getRenderer } from "../../../lib/renderer/Singleton";
import { ScrollState } from "../../../lib/renderer/types";
import { IntermediateContext } from "../../../context/intermediate/Intermediate";
import { useSession } from "../../../controllers/client/ClientController";
import RequiresOnline from "../../../controllers/client/jsx/RequiresOnline";
import { modalController } from "../../../controllers/modals/ModalController";
import ConversationStart from "./ConversationStart";
import MessageRenderer from "./MessageRenderer";
@@ -63,7 +62,6 @@ export const MESSAGE_AREA_PADDING = 82;
export const MessageArea = observer(({ last_id, channel }: Props) => {
const history = useHistory();
const session = useSession()!;
const { focusTaken } = useContext(IntermediateContext);
// ? Required data for message links.
const { message } = useParams<{ message: string }>();
@@ -303,7 +301,7 @@ export const MessageArea = observer(({ last_id, channel }: Props) => {
// ? Scroll to bottom when pressing 'Escape'.
useEffect(() => {
function keyUp(e: KeyboardEvent) {
if (e.key === "Escape" && !focusTaken) {
if (e.key === "Escape" && !modalController.isVisible) {
renderer.jumpToBottom(true);
internalEmit("TextArea", "focus", "message");
}
@@ -311,7 +309,7 @@ export const MessageArea = observer(({ last_id, channel }: Props) => {
document.body.addEventListener("keyup", keyUp);
return () => document.body.removeEventListener("keyup", keyUp);
}, [renderer, ref, focusTaken]);
}, [renderer, ref]);
return (
<MessageAreaWidthContext.Provider

View File

@@ -6,11 +6,6 @@ import { useContext, useEffect, useState } from "preact/hooks";
import TextAreaAutoSize from "../../../lib/TextAreaAutoSize";
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
import {
IntermediateContext,
useIntermediate,
} from "../../../context/intermediate/Intermediate";
import AutoComplete, {
useAutoComplete,
} from "../../../components/common/AutoComplete";
@@ -50,7 +45,6 @@ interface Props {
export default function MessageEditor({ message, finish }: Props) {
const [content, setContent] = useState(message.content ?? "");
const { focusTaken } = useContext(IntermediateContext);
async function save() {
finish();
@@ -70,14 +64,14 @@ export default function MessageEditor({ message, finish }: Props) {
// ? Stop editing when pressing ESC.
useEffect(() => {
function keyUp(e: KeyboardEvent) {
if (e.key === "Escape" && !focusTaken) {
if (e.key === "Escape" && !modalController.isVisible) {
finish();
}
}
document.body.addEventListener("keyup", keyUp);
return () => document.body.removeEventListener("keyup", keyUp);
}, [focusTaken, finish]);
}, [finish]);
const {
onChange,

View File

@@ -16,8 +16,6 @@ import { Button } from "@revoltchat/ui";
import { voiceState, VoiceStatus } from "../../../lib/vortex/VoiceState";
import { useIntermediate } from "../../../context/intermediate/Intermediate";
import Tooltip from "../../../components/common/Tooltip";
import UserIcon from "../../../components/common/user/UserIcon";
import { useClient } from "../../../controllers/client/ClientController";
@@ -85,8 +83,6 @@ const VoiceBase = styled.div`
export default observer(({ id }: Props) => {
if (voiceState.roomId !== id) return null;
const { openScreen } = useIntermediate();
const client = useClient();
const self = client.users.get(client.user!._id);

View File

@@ -12,7 +12,8 @@ import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
import { useApplicationState } from "../../mobx/State";
import { Overrides } from "../../context/Theme";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import { modalController } from "../../controllers/modals/ModalController";
const Container = styled.div`
flex-grow: 1;
@@ -85,7 +86,6 @@ const REMOTE = "https://rvlt.gg";
export default function Discover() {
const state = useApplicationState();
const { openLink } = useIntermediate();
const history = useHistory();
const { pathname, search } = useLocation();
@@ -137,7 +137,7 @@ export default function Discover() {
break;
}
case "navigate": {
openLink(data.url);
modalController.openLink(data.url);
break;
}
case "applyTheme": {

View File

@@ -14,8 +14,6 @@ import { IconButton } from "@revoltchat/ui";
import { stopPropagation } from "../../lib/stopPropagation";
import { voiceState } from "../../lib/vortex/VoiceState";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import UserIcon from "../../components/common/user/UserIcon";
import UserStatus from "../../components/common/user/UserStatus";
import { modalController } from "../../controllers/modals/ModalController";
@@ -26,7 +24,6 @@ interface Props {
export const Friend = observer(({ user }: Props) => {
const history = useHistory();
const { openScreen } = useIntermediate();
const actions: Children[] = [];
let subtext: Children = null;

View File

@@ -12,8 +12,6 @@ import { IconButton } from "@revoltchat/ui";
import { TextReact } from "../../lib/i18n";
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import CollapsibleSection from "../../components/common/CollapsibleSection";
import Tooltip from "../../components/common/Tooltip";
import UserIcon from "../../components/common/user/UserIcon";
@@ -23,8 +21,6 @@ import { modalController } from "../../controllers/modals/ModalController";
import { Friend } from "./Friend";
export default observer(() => {
const { openScreen } = useIntermediate();
const client = useClient();
const users = [...client.users.values()];
users.sort((a, b) => a.username.localeCompare(b.username));

View File

@@ -23,8 +23,6 @@ import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
import { useApplicationState } from "../../mobx/State";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import wideSVG from "/assets/wide.svg";
import { PageHeader } from "../../components/ui/Header";
@@ -45,7 +43,6 @@ const Overlay = styled.div`
`;
export default observer(() => {
const { openScreen } = useIntermediate();
const client = useClient();
const state = useApplicationState();

View File

@@ -15,8 +15,6 @@ import { Text } from "preact-i18n";
import { LineDivider } from "@revoltchat/ui";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import ButtonItem from "../../components/navigation/items/ButtonItem";
import { useClient } from "../../controllers/client/ClientController";
import RequiresOnline from "../../controllers/client/jsx/RequiresOnline";
@@ -30,7 +28,6 @@ import { Overview } from "./server/Overview";
import { Roles } from "./server/Roles";
export default observer(() => {
const { openScreen } = useIntermediate();
const { server: sid } = useParams<{ server: string }>();
const client = useClient();
const server = client.servers.get(sid);

View File

@@ -33,8 +33,6 @@ import { LineDivider } from "@revoltchat/ui";
import { useApplicationState } from "../../mobx/State";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import UserIcon from "../../components/common/user/UserIcon";
import { Username } from "../../components/common/user/UserShort";
import UserStatus from "../../components/common/user/UserStatus";
@@ -121,7 +119,6 @@ const AccountHeader = styled.div`
export default observer(() => {
const history = useHistory();
const client = useClient();
const { openScreen } = useIntermediate();
const experiments = useApplicationState().experiments;
function switchPage(to?: string) {

View File

@@ -23,7 +23,6 @@ import { internalEmit } from "../../../lib/eventEmitter";
import { useTranslation } from "../../../lib/i18n";
import { stopPropagation } from "../../../lib/stopPropagation";
import { useIntermediate } from "../../../context/intermediate/Intermediate";
import { FileUploader } from "../../../context/revoltjs/FileUploads";
import AutoComplete, {
@@ -88,7 +87,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
);
const [interactionsRef, setInteractionsRef] =
useState<HTMLInputElement | null>(null);
const { writeClipboard, openScreen } = useIntermediate();
const [profile, setProfile] = useState<undefined | API.UserProfile>(
undefined,
@@ -267,7 +265,9 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
}>
<a
onClick={() =>
writeClipboard(user!._id)
modalController.writeText(
user!._id,
)
}>
{user!._id}
</a>
@@ -335,7 +335,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
<CategoryButton
account
icon={<Key size={24} />}
onClick={() => writeClipboard(bot.token)}
onClick={() => modalController.writeText(bot.token)}
description={
<>
{"••••• "}
@@ -475,7 +475,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
<>
<Button
onClick={() =>
writeClipboard(
modalController.writeText(
`${window.origin}/bot/${bot._id}`,
)
}>

View File

@@ -14,8 +14,6 @@ import { useAutosave } from "../../../lib/debounce";
import { Draggable, Droppable } from "../../../lib/dnd";
import { noop } from "../../../lib/js";
import { useIntermediate } from "../../../context/intermediate/Intermediate";
import ChannelIcon from "../../../components/common/ChannelIcon";
import { modalController } from "../../../controllers/modals/ModalController";
@@ -334,12 +332,9 @@ function ListElement({
index: number;
setTitle?: (title: string) => void;
deleteSelf?: () => void;
addChannel: (
channel: Channel & { channel_type: "TextChannel" | "VoiceChannel" },
) => void;
addChannel: (channel: Channel) => void;
draggable?: boolean;
}) {
const { openScreen } = useIntermediate();
const [editing, setEditing] = useState<string>();
const startEditing = () => setTitle && setEditing(category.title);