Reset overwrite url if it is invalid (does fail to reach sfu)
This commit is contained in:
@@ -72,6 +72,7 @@
|
|||||||
"save": "Save",
|
"save": "Save",
|
||||||
"saving": "Saving..."
|
"saving": "Saving..."
|
||||||
},
|
},
|
||||||
|
"custom_url_update_reason_invalid": "Auto reset, custom url was invalid!",
|
||||||
"debug_tile_layout_label": "Debug tile layout",
|
"debug_tile_layout_label": "Debug tile layout",
|
||||||
"device_id": "Device ID: {{id}}",
|
"device_id": "Device ID: {{id}}",
|
||||||
"duplicate_tiles_label": "Number of additional tile copies per participant",
|
"duplicate_tiles_label": "Number of additional tile copies per participant",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
matrixRTCMode as matrixRTCModeSetting,
|
matrixRTCMode as matrixRTCModeSetting,
|
||||||
customLivekitUrl as customLivekitUrlSetting,
|
customLivekitUrl as customLivekitUrlSetting,
|
||||||
MatrixRTCMode,
|
MatrixRTCMode,
|
||||||
|
useSettingWithLastUpdateReason,
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
import type { Room as LivekitRoom } from "livekit-client";
|
import type { Room as LivekitRoom } from "livekit-client";
|
||||||
import styles from "./DeveloperSettingsTab.module.css";
|
import styles from "./DeveloperSettingsTab.module.css";
|
||||||
@@ -92,9 +93,8 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
|||||||
alwaysShowIphoneEarpieceSetting,
|
alwaysShowIphoneEarpieceSetting,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [customLivekitUrl, setCustomLivekitUrl] = useSetting(
|
const [customLivekitUrl, setCustomLivekitUrl, customLivekitUrlUpdateReason] =
|
||||||
customLivekitUrlSetting,
|
useSettingWithLastUpdateReason(customLivekitUrlSetting);
|
||||||
);
|
|
||||||
const [customLivekitUrlTextBuffer, setCustomLivekitUrlTextBuffer] =
|
const [customLivekitUrlTextBuffer, setCustomLivekitUrlTextBuffer] =
|
||||||
useState(customLivekitUrl);
|
useState(customLivekitUrl);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -220,7 +220,8 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
|||||||
onSubmit={(e) => e.preventDefault()}
|
onSubmit={(e) => e.preventDefault()}
|
||||||
helpLabel={
|
helpLabel={
|
||||||
customLivekitUrl === null
|
customLivekitUrl === null
|
||||||
? t("developer_mode.custom_livekit_url.from_config")
|
? t("developer_mode.custom_livekit_url.from_config") +
|
||||||
|
(customLivekitUrlUpdateReason ?? "")
|
||||||
: t("developer_mode.custom_livekit_url.current_url") +
|
: t("developer_mode.custom_livekit_url.current_url") +
|
||||||
customLivekitUrl
|
customLivekitUrl
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,15 +34,20 @@ export class Setting<T> {
|
|||||||
|
|
||||||
this._value$ = new BehaviorSubject(initialValue);
|
this._value$ = new BehaviorSubject(initialValue);
|
||||||
this.value$ = this._value$;
|
this.value$ = this._value$;
|
||||||
|
this._lastUpdateReason$ = new BehaviorSubject<string | null>(null);
|
||||||
|
this.lastUpdateReason$ = this._lastUpdateReason$;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly key: string;
|
private readonly key: string;
|
||||||
|
|
||||||
private readonly _value$: BehaviorSubject<T>;
|
private readonly _value$: BehaviorSubject<T>;
|
||||||
|
private readonly _lastUpdateReason$: BehaviorSubject<string | null>;
|
||||||
public readonly value$: Behavior<T>;
|
public readonly value$: Behavior<T>;
|
||||||
|
public readonly lastUpdateReason$: Behavior<string | null>;
|
||||||
|
|
||||||
public readonly setValue = (value: T): void => {
|
public readonly setValue = (value: T, reason?: string): void => {
|
||||||
this._value$.next(value);
|
this._value$.next(value);
|
||||||
|
this._lastUpdateReason$.next(reason ?? null);
|
||||||
localStorage.setItem(this.key, JSON.stringify(value));
|
localStorage.setItem(this.key, JSON.stringify(value));
|
||||||
};
|
};
|
||||||
public readonly getValue = (): T => {
|
public readonly getValue = (): T => {
|
||||||
@@ -57,6 +62,19 @@ export function useSetting<T>(setting: Setting<T>): [T, (value: T) => void] {
|
|||||||
return [useBehavior(setting.value$), setting.setValue];
|
return [useBehavior(setting.value$), setting.setValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* React hook that returns a settings's current value and a setter.
|
||||||
|
*/
|
||||||
|
export function useSettingWithLastUpdateReason<T>(
|
||||||
|
setting: Setting<T>,
|
||||||
|
): [T, (value: T) => void, string | null] {
|
||||||
|
return [
|
||||||
|
useBehavior(setting.value$),
|
||||||
|
setting.setValue,
|
||||||
|
useBehavior(setting.lastUpdateReason$),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// null = undecided
|
// null = undecided
|
||||||
export const optInAnalytics = new Setting<boolean | null>(
|
export const optInAnalytics = new Setting<boolean | null>(
|
||||||
"opt-in-analytics",
|
"opt-in-analytics",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
||||||
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
||||||
|
import { t } from "i18next";
|
||||||
|
|
||||||
import { type Behavior } from "../../Behavior.ts";
|
import { type Behavior } from "../../Behavior.ts";
|
||||||
import { type Epoch, type ObservableScope } from "../../ObservableScope.ts";
|
import { type Epoch, type ObservableScope } from "../../ObservableScope.ts";
|
||||||
@@ -178,11 +179,25 @@ async function makeTransport(
|
|||||||
|
|
||||||
if (!transport) throw new MatrixRTCTransportMissingError(domain ?? ""); // this will call the jwt/sfu/get endpoint to pre create the livekit room.
|
if (!transport) throw new MatrixRTCTransportMissingError(domain ?? ""); // this will call the jwt/sfu/get endpoint to pre create the livekit room.
|
||||||
|
|
||||||
await getSFUConfigWithOpenID(
|
try {
|
||||||
client,
|
await getSFUConfigWithOpenID(
|
||||||
transport.livekit_service_url,
|
client,
|
||||||
transport.livekit_alias,
|
transport.livekit_service_url,
|
||||||
);
|
transport.livekit_alias,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (urlFromDevSettings !== undefined) {
|
||||||
|
logger.error(
|
||||||
|
"Failed to get SFU config with dev settings overwrite, Resetting dev settings",
|
||||||
|
);
|
||||||
|
customLivekitUrl.setValue(
|
||||||
|
null,
|
||||||
|
`\n${t("developer_mode.custom_url_update_reason_invalid")}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return transport;
|
return transport;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user