mirror of https://github.com/vector-im/riot-web
Add labs setting to force small broadcast chunks (#9806)
parent
a1bc4b8e6b
commit
a2777d3a03
|
@ -31,6 +31,7 @@ import { AccountDataExplorer, RoomAccountDataExplorer } from "./devtools/Account
|
||||||
import SettingsFlag from "../elements/SettingsFlag";
|
import SettingsFlag from "../elements/SettingsFlag";
|
||||||
import { SettingLevel } from "../../../settings/SettingLevel";
|
import { SettingLevel } from "../../../settings/SettingLevel";
|
||||||
import ServerInfo from "./devtools/ServerInfo";
|
import ServerInfo from "./devtools/ServerInfo";
|
||||||
|
import { Features } from "../../../settings/Settings";
|
||||||
|
|
||||||
enum Category {
|
enum Category {
|
||||||
Room,
|
Room,
|
||||||
|
@ -105,6 +106,7 @@ const DevtoolsDialog: React.FC<IProps> = ({ roomId, onFinished }) => {
|
||||||
<SettingsFlag name="developerMode" level={SettingLevel.ACCOUNT} />
|
<SettingsFlag name="developerMode" level={SettingLevel.ACCOUNT} />
|
||||||
<SettingsFlag name="showHiddenEventsInTimeline" level={SettingLevel.DEVICE} />
|
<SettingsFlag name="showHiddenEventsInTimeline" level={SettingLevel.DEVICE} />
|
||||||
<SettingsFlag name="enableWidgetScreenshots" level={SettingLevel.ACCOUNT} />
|
<SettingsFlag name="enableWidgetScreenshots" level={SettingLevel.ACCOUNT} />
|
||||||
|
<SettingsFlag name={Features.VoiceBroadcastForceSmallChunks} level={SettingLevel.DEVICE} />
|
||||||
</div>
|
</div>
|
||||||
</BaseTool>
|
</BaseTool>
|
||||||
);
|
);
|
||||||
|
|
|
@ -951,6 +951,7 @@
|
||||||
"Favourite Messages": "Favourite Messages",
|
"Favourite Messages": "Favourite Messages",
|
||||||
"Under active development.": "Under active development.",
|
"Under active development.": "Under active development.",
|
||||||
"Under active development": "Under active development",
|
"Under active development": "Under active development",
|
||||||
|
"Force 15s voice broadcast chunk length": "Force 15s voice broadcast chunk length",
|
||||||
"Use new session manager": "Use new session manager",
|
"Use new session manager": "Use new session manager",
|
||||||
"New session manager": "New session manager",
|
"New session manager": "New session manager",
|
||||||
"Have greater visibility and control over all your sessions.": "Have greater visibility and control over all your sessions.",
|
"Have greater visibility and control over all your sessions.": "Have greater visibility and control over all your sessions.",
|
||||||
|
|
|
@ -90,6 +90,7 @@ export enum LabGroup {
|
||||||
|
|
||||||
export enum Features {
|
export enum Features {
|
||||||
VoiceBroadcast = "feature_voice_broadcast",
|
VoiceBroadcast = "feature_voice_broadcast",
|
||||||
|
VoiceBroadcastForceSmallChunks = "feature_voice_broadcast_force_small_chunks",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const labGroupNames: Record<LabGroup, string> = {
|
export const labGroupNames: Record<LabGroup, string> = {
|
||||||
|
@ -461,6 +462,11 @@ export const SETTINGS: { [setting: string]: ISetting } = {
|
||||||
description: _td("Under active development"),
|
description: _td("Under active development"),
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
[Features.VoiceBroadcastForceSmallChunks]: {
|
||||||
|
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||||
|
displayName: _td("Force 15s voice broadcast chunk length"),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
"feature_new_device_manager": {
|
"feature_new_device_manager": {
|
||||||
isFeature: true,
|
isFeature: true,
|
||||||
labsGroup: LabGroup.Experimental,
|
labsGroup: LabGroup.Experimental,
|
||||||
|
|
|
@ -15,13 +15,17 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SdkConfig, { DEFAULTS } from "../../SdkConfig";
|
import SdkConfig, { DEFAULTS } from "../../SdkConfig";
|
||||||
|
import { Features } from "../../settings/Settings";
|
||||||
|
import SettingsStore from "../../settings/SettingsStore";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the target chunk length for voice broadcasts:
|
* Returns the target chunk length for voice broadcasts:
|
||||||
* - Tries to get the value from the voice_broadcast.chunk_length config
|
* - If {@see Features.VoiceBroadcastForceSmallChunks} is enabled uses 15s chunk length
|
||||||
|
* - Otherwise to get the value from the voice_broadcast.chunk_length config
|
||||||
* - If that fails from DEFAULTS
|
* - If that fails from DEFAULTS
|
||||||
* - If that fails fall back to 120 (two minutes)
|
* - If that fails fall back to 120 (two minutes)
|
||||||
*/
|
*/
|
||||||
export const getChunkLength = (): number => {
|
export const getChunkLength = (): number => {
|
||||||
|
if (SettingsStore.getValue(Features.VoiceBroadcastForceSmallChunks)) return 15;
|
||||||
return SdkConfig.get("voice_broadcast")?.chunk_length || DEFAULTS.voice_broadcast?.chunk_length || 120;
|
return SdkConfig.get("voice_broadcast")?.chunk_length || DEFAULTS.voice_broadcast?.chunk_length || 120;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,8 @@ jest.mock("../../../src/audio/VoiceRecording", () => ({
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock("../../../src/settings/SettingsStore");
|
||||||
|
|
||||||
describe("VoiceBroadcastRecorder", () => {
|
describe("VoiceBroadcastRecorder", () => {
|
||||||
describe("createVoiceBroadcastRecorder", () => {
|
describe("createVoiceBroadcastRecorder", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,6 +17,9 @@ limitations under the License.
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
|
|
||||||
import SdkConfig, { DEFAULTS } from "../../../src/SdkConfig";
|
import SdkConfig, { DEFAULTS } from "../../../src/SdkConfig";
|
||||||
|
import { SettingLevel } from "../../../src/settings/SettingLevel";
|
||||||
|
import { Features } from "../../../src/settings/Settings";
|
||||||
|
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||||
import { getChunkLength } from "../../../src/voice-broadcast/utils/getChunkLength";
|
import { getChunkLength } from "../../../src/voice-broadcast/utils/getChunkLength";
|
||||||
|
|
||||||
jest.mock("../../../src/SdkConfig");
|
jest.mock("../../../src/SdkConfig");
|
||||||
|
@ -48,7 +51,7 @@ describe("getChunkLength", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("if there are no defaults", () => {
|
describe("when there are no defaults", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
DEFAULTS.voice_broadcast = undefined;
|
DEFAULTS.voice_broadcast = undefined;
|
||||||
});
|
});
|
||||||
|
@ -57,4 +60,14 @@ describe("getChunkLength", () => {
|
||||||
expect(getChunkLength()).toBe(120);
|
expect(getChunkLength()).toBe(120);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when the Features.VoiceBroadcastForceSmallChunks is enabled", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await SettingsStore.setValue(Features.VoiceBroadcastForceSmallChunks, null, SettingLevel.DEVICE, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return a chunk length of 15 seconds", () => {
|
||||||
|
expect(getChunkLength()).toBe(15);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue