fix(iOS): actually fix context menus

closes #138
This commit is contained in:
Paul Makles
2022-03-05 14:41:41 +00:00
parent 3e045cf8a8
commit 18761e2181
15 changed files with 90 additions and 61 deletions

View File

@@ -1,7 +1,8 @@
import { observer } from "mobx-react-lite";
import { Message as MessageObject } from "revolt.js/dist/maps/Messages";
import { attachContextMenu } from "preact-context-menu";
import { Ref } from "preact";
import { refContextMenu } from "preact-context-menu";
import { memo } from "preact/compat";
import { useEffect, useState } from "preact/hooks";
@@ -64,7 +65,7 @@ const Message = observer(
// ! TODO: tell fatal to make this type generic
// bree: Fatal please...
const userContext = attachContext
? (attachContextMenu("Menu", {
? (refContextMenu("Menu", {
user: message.author_id,
contextualChannel: message.channel_id,
// eslint-disable-next-line
@@ -119,13 +120,13 @@ const Message = observer(
sending={typeof queued !== "undefined"}
mention={message.mention_ids?.includes(client.user!._id)}
failed={typeof queued?.error !== "undefined"}
onContextMenu={
ref={
attachContext
? attachContextMenu("Menu", {
? (refContextMenu("Menu", {
message,
contextualChannel: message.channel_id,
queued,
})
}) as Ref<HTMLDivElement>)
: undefined
}
onMouseEnter={() => setAnimate(true)}
@@ -137,7 +138,7 @@ const Message = observer(
url={message.generateMasqAvatarURL()}
target={user}
size={36}
onContextMenu={userContext}
innerRef={userContext}
onClick={handleUserClick}
animate={mouseHovering}
showServerIdentity
@@ -154,7 +155,7 @@ const Message = observer(
className="author"
showServerIdentity
onClick={handleUserClick}
onContextMenu={userContext}
innerRef={userContext}
masquerade={message.masquerade!}
/>
<MessageDetail

View File

@@ -15,7 +15,8 @@ import { SystemMessage as SystemMessageI } from "revolt-api/types/Channels";
import { Message } from "revolt.js/dist/maps/Messages";
import styled from "styled-components/macro";
import { attachContextMenu } from "preact-context-menu";
import { Ref } from "preact";
import { refContextMenu } from "preact-context-menu";
import { TextReact } from "../../../lib/i18n";
@@ -138,12 +139,12 @@ export const SystemMessage = observer(
return (
<MessageBase
highlight={highlight}
onContextMenu={
ref={
attachContext
? attachContextMenu("Menu", {
? (refContextMenu("Menu", {
message,
contextualChannel: message.channel,
})
}) as Ref<HTMLDivElement>)
: undefined
}>
{!hideInfo && (

View File

@@ -2,7 +2,7 @@ import { Attachment as AttachmentI } from "revolt-api/types/Autumn";
import styles from "./Attachment.module.scss";
import classNames from "classnames";
import { attachContextMenu } from "preact-context-menu";
import { refContextMenu } from "preact-context-menu";
import { useContext, useState } from "preact/hooks";
import { AppContext } from "../../../../context/revoltjs/RevoltClient";
@@ -37,7 +37,7 @@ export default function Attachment({ attachment, hasContent }: Props) {
<SizedGrid
width={metadata.width}
height={metadata.height}
onContextMenu={attachContextMenu("Menu", {
innerRef={refContextMenu("Menu", {
attachment,
})}
className={classNames({

View File

@@ -1,5 +1,7 @@
import styled from "styled-components/macro";
import { Ref } from "preact";
import { Children } from "../../../../types/Preact";
const Grid = styled.div<{ width: number; height: number }>`
@@ -71,13 +73,14 @@ type Props = Omit<
children?: Children;
width: number;
height: number;
innerRef?: Ref<any>;
};
export function SizedGrid(props: Props) {
const { width, height, children, ...divProps } = props;
const { width, height, children, innerRef, ...divProps } = props;
return (
<Grid {...divProps} width={width} height={height}>
<Grid {...divProps} width={width} height={height} ref={innerRef}>
{children}
</Grid>
);