change how we encode indexeddb key to prevent conflicts

This commit is contained in:
Ajay Bura 2026-10-18 14:48:56 +05:30
commit a978a5b95d
18 changed files with 37 additions and 21 deletions

View file

@ -125,7 +125,7 @@ export function CameraPreview() {
gap="200"
grow="Yes"
>
<Icon src={status === 'idle' ? Icons.User : Icons.Warning} />
<Icon src={status === 'idle' ? Icons.EyeBlind : Icons.Warning} />
<Text size="L400" align="Center">
{STATUS_MESSAGE[status as Exclude<CameraStatus, 'ready'>]}
</Text>

View file

@ -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(() => {

View file

@ -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<CallControlState>;

View file

@ -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<KeyBackup | undefined>;

View file

@ -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[] = [];

View file

@ -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<InboundVerification | OutboundVerification>(
publishKey
);
@ -944,7 +945,7 @@ export const createVerificationRequestObservable = () => {
};
export const createToDeviceEventsObservable = () => {
const publishKey = crypto.randomUUID();
const publishKey = randomStr();
const toDeviceEvents = new Observable<ProcessedToDeviceEvent[]>(publishKey);
const onToDeviceEvents = (events: ProcessedToDeviceEvent[]) => {
@ -1036,7 +1037,7 @@ export const createBackupInfoObservable = async (
secrets: Secrets,
disposer: Disposer
): Promise<ObservableValue<BackupVersionInfo | undefined>> => {
const publishKey = crypto.randomUUID();
const publishKey = randomStr();
const backupInfo = new ObservableValue<BackupVersionInfo | undefined>(undefined, publishKey);
const update = async () => {

View file

@ -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<T extends ClientEventWithoutRoomId> {
export class EncryptedEvent<T extends ClientEventWithoutRoomId> {
private readonly roomEncryption: RoomEncryption;
private readonly publishKey = crypto.randomUUID();
private readonly publishKey = randomStr();
private decryptPromise: Promise<void> | undefined;

View file

@ -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;

View file

@ -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;

View file

@ -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),

View file

@ -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<Map<string, Timeline>> => {
const publishKey: string = crypto.randomUUID();
const publishKey: string = randomStr();
const roomToTimeline = new ObservableValue<Map<string, Timeline>>(new Map(), publishKey);

View file

@ -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<readonly LocalEventSender[]>;

View file

@ -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<void>) {}
@ -35,7 +36,7 @@ export class LocalEventSender<TContent extends object = object> {
private readonly request: MatrixRequest;
private readonly publishKey = crypto.randomUUID();
private readonly publishKey = randomStr();
public readonly state: ObservableValue<LocalEventSenderState>;

View file

@ -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),

View file

@ -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<RangeInfo>;
private readonly publishKey = crypto.randomUUID();
private readonly publishKey = randomStr();
private oldLength: number;

View file

@ -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<T extends RelationType, Content extends Relation<T> = Relation<T>>
implements Disposable
@ -13,7 +14,7 @@ export class Relations<T extends RelationType, Content extends Relation<T> = Rel
Map<string, MessageEventWithoutRoomId<Content>[]>
>;
private publishKey: string = crypto.randomUUID();
private publishKey: string = randomStr();
private disposer = new Disposer();

View file

@ -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<RelationType.Annotation, ReactionContent>;

View file

@ -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}';