diff --git a/package.json b/package.json index d531110f..aa6a3030 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "react-router-dom": "^5.2.0", "react-scroll": "^1.8.2", "redux": "^4.1.0", - "revolt.js": "4.3.3-alpha.15", + "revolt.js": "4.3.3-alpha.16", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/components/common/AutoComplete.tsx b/src/components/common/AutoComplete.tsx index 45b51f1d..8793d561 100644 --- a/src/components/common/AutoComplete.tsx +++ b/src/components/common/AutoComplete.tsx @@ -2,9 +2,9 @@ import { SYSTEM_USER_ID, User } from "revolt.js"; import { Channels } from "revolt.js/dist/api/objects"; import styled, { css } from "styled-components"; -import { StateUpdater, useContext, useState } from "preact/hooks"; +import { StateUpdater, useState } from "preact/hooks"; -import { AppContext } from "../../context/revoltjs/RevoltClient"; +import { useClient } from "../../context/revoltjs/RevoltClient"; import { emojiDictionary } from "../../assets/emojis"; import ChannelIcon from "./ChannelIcon"; @@ -52,7 +52,7 @@ export function useAutoComplete( ): AutoCompleteProps { const [state, setState] = useState({ type: "none" }); const [focused, setFocused] = useState(false); - const client = useContext(AppContext); + const client = useClient(); function findSearchString( el: HTMLTextAreaElement, diff --git a/src/components/common/messaging/embed/Embed.tsx b/src/components/common/messaging/embed/Embed.tsx index 726c60d1..d28fba4d 100644 --- a/src/components/common/messaging/embed/Embed.tsx +++ b/src/components/common/messaging/embed/Embed.tsx @@ -5,6 +5,7 @@ import classNames from "classnames"; import { useContext } from "preact/hooks"; import { useIntermediate } from "../../../../context/intermediate/Intermediate"; +import { useClient } from "../../../../context/revoltjs/RevoltClient"; import { MessageAreaWidthContext } from "../../../../pages/channels/messaging/MessageArea"; import EmbedMedia from "./EmbedMedia"; @@ -19,11 +20,7 @@ const CONTAINER_PADDING = 24; const MAX_PREVIEW_SIZE = 150; export default function Embed({ embed }: Props) { - // ! FIXME: temp code - // ! add proxy function to client - function proxyImage(url: string) { - return `https://jan.revolt.chat/proxy?url=${encodeURIComponent(url)}`; - } + const client = useClient(); const { openScreen } = useIntermediate(); const maxWidth = Math.min( @@ -95,7 +92,7 @@ export default function Embed({ embed }: Props) { {embed.icon_url && ( (e.currentTarget.style.display = @@ -152,9 +149,10 @@ export default function Embed({ embed }: Props) { openScreen({ id: "image_viewer", embed })} onMouseDown={(ev) => ev.button === 1 && window.open(embed.url, "_blank") diff --git a/src/components/common/messaging/embed/EmbedMedia.tsx b/src/components/common/messaging/embed/EmbedMedia.tsx index 81457495..169192e1 100644 --- a/src/components/common/messaging/embed/EmbedMedia.tsx +++ b/src/components/common/messaging/embed/EmbedMedia.tsx @@ -3,6 +3,7 @@ import { Embed } from "revolt.js/dist/api/objects"; import styles from "./Embed.module.scss"; import { useIntermediate } from "../../../../context/intermediate/Intermediate"; +import { useClient } from "../../../../context/revoltjs/RevoltClient"; interface Props { embed: Embed; @@ -11,19 +12,15 @@ interface Props { } export default function EmbedMedia({ embed, width, height }: Props) { - // ! FIXME: temp code - // ! add proxy function to client - function proxyImage(url: string) { - return `https://jan.revolt.chat/proxy?url=${encodeURIComponent(url)}`; - } - if (embed.type !== "Website") return null; const { openScreen } = useIntermediate(); + const client = useClient(); switch (embed.special?.type) { case "YouTube": return (