From 64682d453fd0bad3d09894f0bc190820673dc2b0 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 23 Jun 2021 22:56:44 +0100 Subject: [PATCH] Fix (edited) string on messages. Fix build issues. Remove mediasoup from vendor bundle. --- external/lang | 2 +- package.json | 2 +- .../common/messaging/MessageBase.tsx | 19 ++++++---- src/context/Voice.tsx | 36 ++++++++----------- .../channels/messaging/MessageRenderer.tsx | 6 +++- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/external/lang b/external/lang index 5e57b0f2..be021b37 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 5e57b0f203f1c03c2942222b967288257c218a4e +Subproject commit be021b37763b2b0f8f0367b49f9912add845aa21 diff --git a/package.json b/package.json index e95866ea..7077cd3e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "version": "0.0.0", "scripts": { "dev": "vite", - "build": "rimraf build && tsc --noEmit && vite build", + "build": "rimraf build && vite build", "preview": "vite preview", "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'", "fmt": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'", diff --git a/src/components/common/messaging/MessageBase.tsx b/src/components/common/messaging/MessageBase.tsx index 20473381..435c2f11 100644 --- a/src/components/common/messaging/MessageBase.tsx +++ b/src/components/common/messaging/MessageBase.tsx @@ -61,7 +61,10 @@ export default styled.div` .copy { width: 0; + height: 0; opacity: 0; + display: block; + overflow: hidden; } &:hover { @@ -88,10 +91,12 @@ export const MessageInfo = styled.div` time { opacity: 0; + } + + time, .edited { cursor: default; display: inline; font-size: 10px; - padding-top: 1px; color: var(--tertiary-foreground); } `; @@ -117,14 +122,16 @@ export function MessageDetail({ message, position }: { message: MessageObject, p if (position === 'left') { if (message.edited) { return ( - + <> [] - - - - + + + + + + ) } else { return ( diff --git a/src/context/Voice.tsx b/src/context/Voice.tsx index 935bda52..e78b0918 100644 --- a/src/context/Voice.tsx +++ b/src/context/Voice.tsx @@ -1,8 +1,8 @@ import { createContext } from "preact"; import { Children } from "../types/Preact"; -import VoiceClient from "../lib/vortex/VoiceClient"; import { AppContext } from "./revoltjs/RevoltClient"; -import { ProduceType, VoiceUser } from "../lib/vortex/Types"; +import type VoiceClient from "../lib/vortex/VoiceClient"; +import type { ProduceType, VoiceUser } from "../lib/vortex/Types"; import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks"; export enum VoiceStatus { @@ -22,7 +22,7 @@ export interface VoiceOperations { disconnect: () => void; isProducing: (type: ProduceType) => boolean; startProducing: (type: ProduceType) => Promise; - stopProducing: (type: ProduceType) => Promise; + stopProducing: (type: ProduceType) => Promise | undefined; } export interface VoiceState { @@ -31,14 +31,6 @@ export interface VoiceState { participants?: Readonly>; } -export interface VoiceOperations { - connect: (channelId: string) => Promise; - disconnect: () => void; - isProducing: (type: ProduceType) => boolean; - startProducing: (type: ProduceType) => Promise; - stopProducing: (type: ProduceType) => Promise; -} - export const VoiceContext = createContext(undefined as any); export const VoiceOperationsContext = createContext(undefined as any); @@ -48,7 +40,7 @@ type Props = { export default function Voice({ children }: Props) { const revoltClient = useContext(AppContext); - const [client,] = useState(new VoiceClient()); + const [client,] = useState(undefined); const [state, setState] = useState({ status: VoiceStatus.LOADING, participants: new Map() @@ -57,13 +49,13 @@ export default function Voice({ children }: Props) { function setStatus(status: VoiceStatus, roomId?: string) { setState({ status, - roomId: roomId ?? client.roomId, - participants: client.participants ?? new Map(), + roomId: roomId ?? client?.roomId, + participants: client?.participants ?? new Map(), }); } useEffect(() => { - if (!client.supported()) { + if (!client?.supported()) { setStatus(VoiceStatus.UNAVAILABLE); } else { setStatus(VoiceStatus.READY); @@ -74,7 +66,7 @@ export default function Voice({ children }: Props) { const operations: VoiceOperations = useMemo(() => { return { connect: async channelId => { - if (!client.supported()) + if (!client?.supported()) throw new Error("RTC is unavailable"); isConnecting.current = true; @@ -109,7 +101,7 @@ export default function Voice({ children }: Props) { isConnecting.current = false; }, disconnect: () => { - if (!client.supported()) + if (!client?.supported()) throw new Error("RTC is unavailable"); // if (status <= VoiceStatus.READY) return; @@ -122,13 +114,13 @@ export default function Voice({ children }: Props) { isProducing: (type: ProduceType) => { switch (type) { case "audio": - return client.audioProducer !== undefined; + return client?.audioProducer !== undefined; } }, startProducing: async (type: ProduceType) => { switch (type) { case "audio": { - if (client.audioProducer !== undefined) return; + if (client?.audioProducer !== undefined) return; if (navigator.mediaDevices === undefined) return; const mediaStream = await navigator.mediaDevices.getUserMedia( { @@ -136,7 +128,7 @@ export default function Voice({ children }: Props) { } ); - await client.startProduce( + await client?.startProduce( mediaStream.getAudioTracks()[0], "audio" ); @@ -145,13 +137,13 @@ export default function Voice({ children }: Props) { } }, stopProducing: (type: ProduceType) => { - return client.stopProduce(type); + return client?.stopProduce(type); } } }, [ client ]); useEffect(() => { - if (!client.supported()) return; + if (!client?.supported()) return; /* client.on("startProduce", forceUpdate); client.on("stopProduce", forceUpdate); diff --git a/src/pages/channels/messaging/MessageRenderer.tsx b/src/pages/channels/messaging/MessageRenderer.tsx index fba6b281..1eae8e7e 100644 --- a/src/pages/channels/messaging/MessageRenderer.tsx +++ b/src/pages/channels/messaging/MessageRenderer.tsx @@ -139,7 +139,11 @@ function MessageRenderer({ id, state, queue }: Props) { } render.push( - x.id) + }} key={msg.id} queued={msg} head={head}