- writeClipboard(
+ modalController.writeText(
client.user!.username,
)
}>
diff --git a/src/pages/RevoltApp.tsx b/src/pages/RevoltApp.tsx
index c04917ab..23849dd6 100644
--- a/src/pages/RevoltApp.tsx
+++ b/src/pages/RevoltApp.tsx
@@ -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() {
-
>
diff --git a/src/pages/channels/actions/HeaderActions.tsx b/src/pages/channels/actions/HeaderActions.tsx
index 04cbe198..cf13311b 100644
--- a/src/pages/channels/actions/HeaderActions.tsx
+++ b/src/pages/channels/actions/HeaderActions.tsx
@@ -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() {
diff --git a/src/pages/channels/messaging/MessageArea.tsx b/src/pages/channels/messaging/MessageArea.tsx
index c35878d9..d0ae8a5f 100644
--- a/src/pages/channels/messaging/MessageArea.tsx
+++ b/src/pages/channels/messaging/MessageArea.tsx
@@ -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 (
{
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,
diff --git a/src/pages/channels/voice/VoiceHeader.tsx b/src/pages/channels/voice/VoiceHeader.tsx
index 89ef577c..618baaa2 100644
--- a/src/pages/channels/voice/VoiceHeader.tsx
+++ b/src/pages/channels/voice/VoiceHeader.tsx
@@ -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);
diff --git a/src/pages/discover/Discover.tsx b/src/pages/discover/Discover.tsx
index 66fb7268..666daeed 100644
--- a/src/pages/discover/Discover.tsx
+++ b/src/pages/discover/Discover.tsx
@@ -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": {
diff --git a/src/pages/friends/Friend.tsx b/src/pages/friends/Friend.tsx
index 7e3c1ef1..4bdd9c7c 100644
--- a/src/pages/friends/Friend.tsx
+++ b/src/pages/friends/Friend.tsx
@@ -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;
diff --git a/src/pages/friends/Friends.tsx b/src/pages/friends/Friends.tsx
index a479b46b..e4374a26 100644
--- a/src/pages/friends/Friends.tsx
+++ b/src/pages/friends/Friends.tsx
@@ -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));
diff --git a/src/pages/home/Home.tsx b/src/pages/home/Home.tsx
index 67784147..75609150 100644
--- a/src/pages/home/Home.tsx
+++ b/src/pages/home/Home.tsx
@@ -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();
diff --git a/src/pages/settings/ServerSettings.tsx b/src/pages/settings/ServerSettings.tsx
index 72f2925f..d008cf0a 100644
--- a/src/pages/settings/ServerSettings.tsx
+++ b/src/pages/settings/ServerSettings.tsx
@@ -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);
diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx
index 022f0c85..18566e5c 100644
--- a/src/pages/settings/Settings.tsx
+++ b/src/pages/settings/Settings.tsx
@@ -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) {
diff --git a/src/pages/settings/panes/MyBots.tsx b/src/pages/settings/panes/MyBots.tsx
index 158ca952..122ae7ff 100644
--- a/src/pages/settings/panes/MyBots.tsx
+++ b/src/pages/settings/panes/MyBots.tsx
@@ -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(null);
- const { writeClipboard, openScreen } = useIntermediate();
const [profile, setProfile] = useState(
undefined,
@@ -267,7 +265,9 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
}>
- writeClipboard(user!._id)
+ modalController.writeText(
+ user!._id,
+ )
}>
{user!._id}
@@ -335,7 +335,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
}
- onClick={() => writeClipboard(bot.token)}
+ onClick={() => modalController.writeText(bot.token)}
description={
<>
{"••••• "}
@@ -475,7 +475,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
<>