mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-25 06:40:26 +00:00
better typescript
This commit is contained in:
@@ -153,7 +153,7 @@ export class AndroidControlledAudioOutput implements MediaDevice<
|
||||
|
||||
// Merge the two possible inputs observable as a single
|
||||
// stream of actions that will update the state of the controller.
|
||||
const actions$ = merge(
|
||||
const actions$: Observable<ControllerAction> = merge(
|
||||
this.controlledDevices$.pipe(
|
||||
map(
|
||||
(devices) =>
|
||||
@@ -177,34 +177,35 @@ export class AndroidControlledAudioOutput implements MediaDevice<
|
||||
actions$.pipe(
|
||||
startWith(initialAction),
|
||||
scan((state, action): ControllerState => {
|
||||
if (action.type === "deviceUpdated") {
|
||||
const chosenDevice = this.chooseEffectiveSelection({
|
||||
previousDevices: state.devices,
|
||||
availableDevices: action.devices,
|
||||
currentSelectedId: state.selectedDeviceId,
|
||||
preferredDeviceId: state.preferredDeviceId,
|
||||
});
|
||||
switch (action.type) {
|
||||
case "deviceUpdated": {
|
||||
const chosenDevice = this.chooseEffectiveSelection({
|
||||
previousDevices: state.devices,
|
||||
availableDevices: action.devices,
|
||||
currentSelectedId: state.selectedDeviceId,
|
||||
preferredDeviceId: state.preferredDeviceId,
|
||||
});
|
||||
|
||||
return {
|
||||
...state,
|
||||
devices: action.devices,
|
||||
selectedDeviceId: chosenDevice,
|
||||
};
|
||||
} else if (action.type === "selectDevice") {
|
||||
const chosenDevice = this.chooseEffectiveSelection({
|
||||
previousDevices: state.devices,
|
||||
availableDevices: state.devices,
|
||||
currentSelectedId: state.selectedDeviceId,
|
||||
preferredDeviceId: action.deviceId,
|
||||
});
|
||||
return {
|
||||
...state,
|
||||
devices: action.devices,
|
||||
selectedDeviceId: chosenDevice,
|
||||
};
|
||||
}
|
||||
case "selectDevice": {
|
||||
const chosenDevice = this.chooseEffectiveSelection({
|
||||
previousDevices: state.devices,
|
||||
availableDevices: state.devices,
|
||||
currentSelectedId: state.selectedDeviceId,
|
||||
preferredDeviceId: action.deviceId,
|
||||
});
|
||||
|
||||
return {
|
||||
...state,
|
||||
preferredDeviceId: action.deviceId,
|
||||
selectedDeviceId: chosenDevice,
|
||||
};
|
||||
} else {
|
||||
return state;
|
||||
return {
|
||||
...state,
|
||||
preferredDeviceId: action.deviceId,
|
||||
selectedDeviceId: chosenDevice,
|
||||
};
|
||||
}
|
||||
}
|
||||
}, initialState),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user