mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
Fix (edited) string on messages.
Fix build issues. Remove mediasoup from vendor bundle.
This commit is contained in:
parent
50bd6addb4
commit
64682d453f
5 changed files with 34 additions and 31 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 5e57b0f203f1c03c2942222b967288257c218a4e
|
||||
Subproject commit be021b37763b2b0f8f0367b49f9912add845aa21
|
|
@ -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}'",
|
||||
|
|
|
@ -61,7 +61,10 @@ export default styled.div<BaseMessageProps>`
|
|||
|
||||
.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 (
|
||||
<span>
|
||||
<>
|
||||
<span className="copy">
|
||||
[<time>{dayjs(decodeTime(message._id)).format("H:mm")}</time>]
|
||||
</span>
|
||||
<Tooltip content={dayjs(message.edited).format("LLLL")}>
|
||||
<Text id="app.main.channel.edited" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<span className="edited">
|
||||
<Tooltip content={dayjs(message.edited).format("LLLL")}>
|
||||
<Text id="app.main.channel.edited" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
|
|
|
@ -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<void>;
|
||||
stopProducing: (type: ProduceType) => Promise<void>;
|
||||
stopProducing: (type: ProduceType) => Promise<void> | undefined;
|
||||
}
|
||||
|
||||
export interface VoiceState {
|
||||
|
@ -31,14 +31,6 @@ export interface VoiceState {
|
|||
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 VoiceOperationsContext = createContext<VoiceOperations>(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<VoiceClient | undefined>(undefined);
|
||||
const [state, setState] = useState<VoiceState>({
|
||||
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);
|
||||
|
|
|
@ -139,7 +139,11 @@ function MessageRenderer({ id, state, queue }: Props) {
|
|||
}
|
||||
|
||||
render.push(
|
||||
<Message message={msg.data}
|
||||
<Message
|
||||
message={{
|
||||
...msg.data,
|
||||
replies: msg.data.replies.map(x => x.id)
|
||||
}}
|
||||
key={msg.id}
|
||||
queued={msg}
|
||||
head={head}
|
||||
|
|
Loading…
Reference in a new issue