Fix (edited) string on messages.

Fix build issues.
Remove mediasoup from vendor bundle.
This commit is contained in:
Paul 2021-06-23 22:56:44 +01:00
parent 50bd6addb4
commit 64682d453f
5 changed files with 34 additions and 31 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit 5e57b0f203f1c03c2942222b967288257c218a4e Subproject commit be021b37763b2b0f8f0367b49f9912add845aa21

View file

@ -2,7 +2,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "rimraf build && tsc --noEmit && vite build", "build": "rimraf build && vite build",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'", "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"fmt": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'", "fmt": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'",

View file

@ -61,7 +61,10 @@ export default styled.div<BaseMessageProps>`
.copy { .copy {
width: 0; width: 0;
height: 0;
opacity: 0; opacity: 0;
display: block;
overflow: hidden;
} }
&:hover { &:hover {
@ -88,10 +91,12 @@ export const MessageInfo = styled.div`
time { time {
opacity: 0; opacity: 0;
}
time, .edited {
cursor: default; cursor: default;
display: inline; display: inline;
font-size: 10px; font-size: 10px;
padding-top: 1px;
color: var(--tertiary-foreground); color: var(--tertiary-foreground);
} }
`; `;
@ -117,14 +122,16 @@ export function MessageDetail({ message, position }: { message: MessageObject, p
if (position === 'left') { if (position === 'left') {
if (message.edited) { if (message.edited) {
return ( return (
<span> <>
<span className="copy"> <span className="copy">
[<time>{dayjs(decodeTime(message._id)).format("H:mm")}</time>] [<time>{dayjs(decodeTime(message._id)).format("H:mm")}</time>]
</span> </span>
<Tooltip content={dayjs(message.edited).format("LLLL")}> <span className="edited">
<Text id="app.main.channel.edited" /> <Tooltip content={dayjs(message.edited).format("LLLL")}>
</Tooltip> <Text id="app.main.channel.edited" />
</span> </Tooltip>
</span>
</>
) )
} else { } else {
return ( return (

View file

@ -1,8 +1,8 @@
import { createContext } from "preact"; import { createContext } from "preact";
import { Children } from "../types/Preact"; import { Children } from "../types/Preact";
import VoiceClient from "../lib/vortex/VoiceClient";
import { AppContext } from "./revoltjs/RevoltClient"; 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"; import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
export enum VoiceStatus { export enum VoiceStatus {
@ -22,7 +22,7 @@ export interface VoiceOperations {
disconnect: () => void; disconnect: () => void;
isProducing: (type: ProduceType) => boolean; isProducing: (type: ProduceType) => boolean;
startProducing: (type: ProduceType) => Promise<void>; startProducing: (type: ProduceType) => Promise<void>;
stopProducing: (type: ProduceType) => Promise<void>; stopProducing: (type: ProduceType) => Promise<void> | undefined;
} }
export interface VoiceState { export interface VoiceState {
@ -31,14 +31,6 @@ export interface VoiceState {
participants?: Readonly<Map<string, VoiceUser>>; participants?: Readonly<Map<string, VoiceUser>>;
} }
export interface VoiceOperations {
connect: (channelId: string) => Promise<void>;
disconnect: () => void;
isProducing: (type: ProduceType) => boolean;
startProducing: (type: ProduceType) => Promise<void>;
stopProducing: (type: ProduceType) => Promise<void>;
}
export const VoiceContext = createContext<VoiceState>(undefined as any); export const VoiceContext = createContext<VoiceState>(undefined as any);
export const VoiceOperationsContext = createContext<VoiceOperations>(undefined as any); export const VoiceOperationsContext = createContext<VoiceOperations>(undefined as any);
@ -48,7 +40,7 @@ type Props = {
export default function Voice({ children }: Props) { export default function Voice({ children }: Props) {
const revoltClient = useContext(AppContext); const revoltClient = useContext(AppContext);
const [client,] = useState(new VoiceClient()); const [client,] = useState<VoiceClient | undefined>(undefined);
const [state, setState] = useState<VoiceState>({ const [state, setState] = useState<VoiceState>({
status: VoiceStatus.LOADING, status: VoiceStatus.LOADING,
participants: new Map() participants: new Map()
@ -57,13 +49,13 @@ export default function Voice({ children }: Props) {
function setStatus(status: VoiceStatus, roomId?: string) { function setStatus(status: VoiceStatus, roomId?: string) {
setState({ setState({
status, status,
roomId: roomId ?? client.roomId, roomId: roomId ?? client?.roomId,
participants: client.participants ?? new Map(), participants: client?.participants ?? new Map(),
}); });
} }
useEffect(() => { useEffect(() => {
if (!client.supported()) { if (!client?.supported()) {
setStatus(VoiceStatus.UNAVAILABLE); setStatus(VoiceStatus.UNAVAILABLE);
} else { } else {
setStatus(VoiceStatus.READY); setStatus(VoiceStatus.READY);
@ -74,7 +66,7 @@ export default function Voice({ children }: Props) {
const operations: VoiceOperations = useMemo(() => { const operations: VoiceOperations = useMemo(() => {
return { return {
connect: async channelId => { connect: async channelId => {
if (!client.supported()) if (!client?.supported())
throw new Error("RTC is unavailable"); throw new Error("RTC is unavailable");
isConnecting.current = true; isConnecting.current = true;
@ -109,7 +101,7 @@ export default function Voice({ children }: Props) {
isConnecting.current = false; isConnecting.current = false;
}, },
disconnect: () => { disconnect: () => {
if (!client.supported()) if (!client?.supported())
throw new Error("RTC is unavailable"); throw new Error("RTC is unavailable");
// if (status <= VoiceStatus.READY) return; // if (status <= VoiceStatus.READY) return;
@ -122,13 +114,13 @@ export default function Voice({ children }: Props) {
isProducing: (type: ProduceType) => { isProducing: (type: ProduceType) => {
switch (type) { switch (type) {
case "audio": case "audio":
return client.audioProducer !== undefined; return client?.audioProducer !== undefined;
} }
}, },
startProducing: async (type: ProduceType) => { startProducing: async (type: ProduceType) => {
switch (type) { switch (type) {
case "audio": { case "audio": {
if (client.audioProducer !== undefined) return; if (client?.audioProducer !== undefined) return;
if (navigator.mediaDevices === undefined) return; if (navigator.mediaDevices === undefined) return;
const mediaStream = await navigator.mediaDevices.getUserMedia( 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], mediaStream.getAudioTracks()[0],
"audio" "audio"
); );
@ -145,13 +137,13 @@ export default function Voice({ children }: Props) {
} }
}, },
stopProducing: (type: ProduceType) => { stopProducing: (type: ProduceType) => {
return client.stopProduce(type); return client?.stopProduce(type);
} }
} }
}, [ client ]); }, [ client ]);
useEffect(() => { useEffect(() => {
if (!client.supported()) return; if (!client?.supported()) return;
/* client.on("startProduce", forceUpdate); /* client.on("startProduce", forceUpdate);
client.on("stopProduce", forceUpdate); client.on("stopProduce", forceUpdate);

View file

@ -139,7 +139,11 @@ function MessageRenderer({ id, state, queue }: Props) {
} }
render.push( render.push(
<Message message={msg.data} <Message
message={{
...msg.data,
replies: msg.data.replies.map(x => x.id)
}}
key={msg.id} key={msg.id}
queued={msg} queued={msg}
head={head} head={head}