diff --git a/src/app/features/call/CameraPreview.tsx b/src/app/features/call/CameraPreview.tsx index 9ca8da7a..9ef670de 100644 --- a/src/app/features/call/CameraPreview.tsx +++ b/src/app/features/call/CameraPreview.tsx @@ -125,7 +125,7 @@ export function CameraPreview() { gap="200" grow="Yes" > - + {STATUS_MESSAGE[status as Exclude]} diff --git a/src/app/hooks/useSingleSessionTab.ts b/src/app/hooks/useSingleSessionTab.ts index ab8da517..ad794712 100644 --- a/src/app/hooks/useSingleSessionTab.ts +++ b/src/app/hooks/useSingleSessionTab.ts @@ -1,11 +1,12 @@ import { useEffect, useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; import { getRootPath } from '../pages/pathUtils'; +import { randomStr } from '../utils/common'; export const useSingleSessionTab = (userId?: string) => { const broadcast = useMemo(() => new BroadcastChannel('in.cinny.broadcast'), []); - const tabId = useMemo(() => crypto.randomUUID(), []); + const tabId = useMemo(() => randomStr(), []); const navigate = useNavigate(); useEffect(() => { diff --git a/src/app/plugins/call/CallControl.ts b/src/app/plugins/call/CallControl.ts index 211280f4..3c073af7 100644 --- a/src/app/plugins/call/CallControl.ts +++ b/src/app/plugins/call/CallControl.ts @@ -3,13 +3,14 @@ import { ObservableValue } from 'neurone/lib/utils/observable'; import { Disposable } from 'neurone/lib/utils/disposable'; import { CallControlState } from './CallControlState'; import { ElementMediaStateDetail, ElementMediaStatePayload, ElementWidgetActions } from './types'; +import { randomStr } from '../../utils/common'; export enum CallControlEvent { StateUpdate = 'state_update', } export class CallControl implements CallControlState, Disposable { - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly state: ObservableValue; diff --git a/src/client/MegolmBackup.ts b/src/client/MegolmBackup.ts index 5d19c8ba..990d1e57 100644 --- a/src/client/MegolmBackup.ts +++ b/src/client/MegolmBackup.ts @@ -7,6 +7,7 @@ import { Base64 } from 'neurone/lib/utils'; import { Disposable, Disposer } from 'neurone/lib/utils/disposable'; import { ObservableValue } from 'neurone/lib/utils/observable'; import { ProgressCallback, responseProgress } from './responseProgress'; +import { randomStr } from '../app/utils/common'; export type ImportBackupIdle = { type: 'idle'; @@ -43,7 +44,7 @@ export type BackupRestoreState = export class MegolmBackup implements Disposable { private readonly disposer = new Disposer(); - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly keyBackup: ObservableValue; diff --git a/src/client/call/CallSession.ts b/src/client/call/CallSession.ts index 689f8677..39a20d6d 100644 --- a/src/client/call/CallSession.ts +++ b/src/client/call/CallSession.ts @@ -10,6 +10,7 @@ import { getJoinRoomMemberId, } from '../storage/collections'; import { CALL_APPLICATION_TYPE, DEFAULT_CALL_SLOT_IDS, resolveActiveRtcMembers } from './rtcMember'; +import { randomStr } from '../../app/utils/common'; export type CallMember = { kind: 'call.member' | 'rtc.member'; @@ -71,7 +72,7 @@ export class CallSession implements Disposable { private readonly storage: Storage; - private readonly publisherKey = crypto.randomUUID(); + private readonly publisherKey = randomStr(); private callEvents: JoinRoomStateObject[] = []; diff --git a/src/client/context.ts b/src/client/context.ts index 4dde5291..68065c69 100644 --- a/src/client/context.ts +++ b/src/client/context.ts @@ -32,6 +32,7 @@ import { AccountDataType } from '../types/matrix/accountData'; import { DecryptionManager } from './decryption'; import { MegolmBackup } from './MegolmBackup'; import { CallSessions } from './call'; +import { randomStr } from '../app/utils/common'; export type StateContext = { join: { @@ -929,7 +930,7 @@ export const createPendingMemberRoomObservable = async ( }; export const createVerificationRequestObservable = () => { - const publishKey = crypto.randomUUID(); + const publishKey = randomStr(); const verificationRequest = new Observable( publishKey ); @@ -944,7 +945,7 @@ export const createVerificationRequestObservable = () => { }; export const createToDeviceEventsObservable = () => { - const publishKey = crypto.randomUUID(); + const publishKey = randomStr(); const toDeviceEvents = new Observable(publishKey); const onToDeviceEvents = (events: ProcessedToDeviceEvent[]) => { @@ -1036,7 +1037,7 @@ export const createBackupInfoObservable = async ( secrets: Secrets, disposer: Disposer ): Promise> => { - const publishKey = crypto.randomUUID(); + const publishKey = randomStr(); const backupInfo = new ObservableValue(undefined, publishKey); const update = async () => { diff --git a/src/client/decryption/EncryptedEvent.ts b/src/client/decryption/EncryptedEvent.ts index a48b6d41..42d6f160 100644 --- a/src/client/decryption/EncryptedEvent.ts +++ b/src/client/decryption/EncryptedEvent.ts @@ -5,6 +5,7 @@ import { } from 'neurone/lib/api/types'; import { MegolmDecryptionError, RoomEncryption } from 'neurone/lib/crypto/machine'; import { ObservableValue } from 'neurone/lib/utils/observable'; +import { randomStr } from '../../app/utils/common'; export class EventDecryptionIdle {} @@ -36,7 +37,7 @@ export class EventDecryptionSuccess { export class EncryptedEvent { private readonly roomEncryption: RoomEncryption; - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); private decryptPromise: Promise | undefined; diff --git a/src/client/room/ThreadTimeline.ts b/src/client/room/ThreadTimeline.ts index 3cd05844..f92f5063 100644 --- a/src/client/room/ThreadTimeline.ts +++ b/src/client/room/ThreadTimeline.ts @@ -23,6 +23,7 @@ import { rRelations, rThread, rUnsigned } from '../reader'; import { TimelineUtils } from './TimelineUtils'; import { LocalEventOutbox } from './local-event/LocalEventOutbox'; import { EventSenderIdle, LocalEvent, LocalEventSender, LocalMessage } from './local-event'; +import { randomStr } from '../../app/utils/common'; export type ThreadSyncData = { events: MessageEventWithoutRoomId[]; @@ -31,7 +32,7 @@ export type ThreadSyncData = { }; export class ThreadTimeline implements TimelineView, Disposable { - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly roomId: string; diff --git a/src/client/room/Timeline.ts b/src/client/room/Timeline.ts index f3f63468..ce3f9d1c 100644 --- a/src/client/room/Timeline.ts +++ b/src/client/room/Timeline.ts @@ -25,9 +25,10 @@ import { getThreadId } from '../../app/utils/room'; import { TimelineUtils } from './TimelineUtils'; import { EventSenderIdle, LocalEvent, LocalEventSender, LocalMessage } from './local-event'; import { LocalEventOutbox } from './local-event/LocalEventOutbox'; +import { randomStr } from '../../app/utils/common'; export class Timeline implements TimelineView, Disposable { - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly roomId: string; diff --git a/src/client/room/TimelineBatchManager.ts b/src/client/room/TimelineBatchManager.ts index 61a72a82..f4bb84e5 100644 --- a/src/client/room/TimelineBatchManager.ts +++ b/src/client/room/TimelineBatchManager.ts @@ -1,6 +1,7 @@ import { MessageEventWithoutRoomId } from 'neurone/lib/api/types'; import { ObservableValue } from 'neurone/lib/utils/observable'; import { MessageBatch, Messages, BatchInfo, BatchChange } from './messages'; +import { randomStr } from '../../app/utils/common'; export class TimelineBatchManager { private readonly publishKey: string; @@ -30,7 +31,7 @@ export class TimelineBatchManager { this.batch.publish( this.publishKey, new MessageBatch( - crypto.randomUUID(), + randomStr(), this.batch.read.messages, this.batch.read.prev, new BatchInfo(undefined, false), @@ -117,7 +118,7 @@ export class TimelineBatchManager { public loadEvents(events: MessageEventWithoutRoomId[], prevToken?: string, nextToken?: string) { const newBatch = new MessageBatch( - crypto.randomUUID(), + randomStr(), new Messages(events), new BatchInfo(prevToken, !prevToken), new BatchInfo(nextToken, !nextToken), diff --git a/src/client/room/index.ts b/src/client/room/index.ts index 012879e4..52857ff7 100644 --- a/src/client/room/index.ts +++ b/src/client/room/index.ts @@ -4,6 +4,7 @@ import { JoinRoom } from 'neurone/lib/api/matrix/client/v3/sync'; import { MatrixRequest } from 'neurone/lib/matrix-request'; import { Timeline } from './Timeline'; import { SyncValue } from '../sync'; +import { randomStr } from '../../app/utils/common'; export * from './Timeline'; export * from './TimelineView'; @@ -14,7 +15,7 @@ export const createTimelines = ( request: MatrixRequest, disposer: Disposer ): ObservableValue> => { - const publishKey: string = crypto.randomUUID(); + const publishKey: string = randomStr(); const roomToTimeline = new ObservableValue>(new Map(), publishKey); diff --git a/src/client/room/local-event/LocalEventOutbox.ts b/src/client/room/local-event/LocalEventOutbox.ts index 0e2c67ca..23b532b5 100644 --- a/src/client/room/local-event/LocalEventOutbox.ts +++ b/src/client/room/local-event/LocalEventOutbox.ts @@ -1,8 +1,9 @@ import { ObservableValue } from 'neurone/lib/utils/observable'; import { EventSenderSuccess, LocalEventSender } from './LocalEventSender'; +import { randomStr } from '../../../app/utils/common'; export class LocalEventOutbox { - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly senders: ObservableValue; diff --git a/src/client/room/local-event/LocalEventSender.ts b/src/client/room/local-event/LocalEventSender.ts index 7126823c..ef1a6d37 100644 --- a/src/client/room/local-event/LocalEventSender.ts +++ b/src/client/room/local-event/LocalEventSender.ts @@ -3,6 +3,7 @@ import { MatrixError, MatrixRequest, parseMatrixResp } from 'neurone/lib/matrix- import { ObservableValue } from 'neurone/lib/utils/observable'; import to from 'await-to-js'; import { LocalEvent } from './LocalEvent'; +import { randomStr } from '../../../app/utils/common'; export class EventSenderIdle { constructor(public readonly send: () => Promise) {} @@ -35,7 +36,7 @@ export class LocalEventSender { private readonly request: MatrixRequest; - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly state: ObservableValue; diff --git a/src/client/room/messages/MessageBatch.ts b/src/client/room/messages/MessageBatch.ts index a9d5d8b1..49e71150 100644 --- a/src/client/room/messages/MessageBatch.ts +++ b/src/client/room/messages/MessageBatch.ts @@ -1,6 +1,7 @@ import { BatchChange } from './BatchChange'; import { BatchInfo } from './BatchInfo'; import { Messages } from '.'; +import { randomStr } from '../../../app/utils/common'; export class MessageBatch { public readonly id: string; @@ -15,7 +16,7 @@ export class MessageBatch { static emptyAtForwardEnd(): MessageBatch { return new MessageBatch( - crypto.randomUUID(), + randomStr(), new Messages([]), new BatchInfo(), new BatchInfo(undefined, true), diff --git a/src/client/room/messages/MessageRange.ts b/src/client/room/messages/MessageRange.ts index 41e9b0f4..b7808544 100644 --- a/src/client/room/messages/MessageRange.ts +++ b/src/client/room/messages/MessageRange.ts @@ -1,6 +1,7 @@ import { Disposable, Disposer } from 'neurone/lib/utils/disposable'; import { ObservableValue } from 'neurone/lib/utils/observable'; import { MessageBatch } from './MessageBatch'; +import { randomStr } from '../../../app/utils/common'; export type RangeInfo = { start: number; @@ -12,7 +13,7 @@ export class MessageRange implements Disposable { public readonly info: ObservableValue; - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); private oldLength: number; diff --git a/src/client/room/relations/Relations.ts b/src/client/room/relations/Relations.ts index c59029b8..20fb707e 100644 --- a/src/client/room/relations/Relations.ts +++ b/src/client/room/relations/Relations.ts @@ -3,6 +3,7 @@ import { Disposable, Disposer } from 'neurone/lib/utils/disposable'; import { ObservableValue } from 'neurone/lib/utils/observable'; import { Relation, RelationType } from '../../../types/matrix/common'; import { rContent, rRelatesTo } from '../../reader'; +import { randomStr } from '../../../app/utils/common'; export class Relations = Relation> implements Disposable @@ -13,7 +14,7 @@ export class Relations = Rel Map[]> >; - private publishKey: string = crypto.randomUUID(); + private publishKey: string = randomStr(); private disposer = new Disposer(); diff --git a/src/client/room/relations/RelationsProcessor.ts b/src/client/room/relations/RelationsProcessor.ts index 7eeb4478..b9d48f91 100644 --- a/src/client/room/relations/RelationsProcessor.ts +++ b/src/client/room/relations/RelationsProcessor.ts @@ -5,9 +5,10 @@ import { MessageEvent } from '../../../types/matrix/room'; import { Relations } from './Relations'; import { RelationType, ReactionContent } from '../../../types/matrix/common'; import { getRedactedEventId, redacted, reference, relation, replaced, replacement } from './utils'; +import { randomStr } from '../../../app/utils/common'; export class RelationsProcessor implements Disposable { - private readonly publishKey = crypto.randomUUID(); + private readonly publishKey = randomStr(); public readonly reactions: Relations; diff --git a/src/client/storage/utils.ts b/src/client/storage/utils.ts index 77a96abe..a19e1252 100644 --- a/src/client/storage/utils.ts +++ b/src/client/storage/utils.ts @@ -1,2 +1,2 @@ -export const encodeKey = (...args: string[]): string => args.join(''); +export const encodeKey = (...args: string[]): string => args.join('+'); export const MAX_UNICODE = '\u{10FFFF}';