Skip to content

Commit ed69aca

Browse files
committed
wip: not showing all options
1 parent 2130558 commit ed69aca

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

packages/webui/src/client/ui/Settings/Studio/Devices/ParentDevices.tsx

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ import { unprotectString } from '@sofie-automation/corelib/dist/protectedString'
2020
import { SchemaFormWithOverrides } from '../../../../lib/forms/SchemaFormWithOverrides'
2121
import { LabelActual, LabelAndOverrides } from '../../../../lib/Components/LabelAndOverrides'
2222
import { getRandomString, literal } from '@sofie-automation/corelib/dist/lib'
23-
import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
2423
import { StudioDeviceSettings } from '@sofie-automation/corelib/dist/dataModel/Studio'
2524
import {
2625
SomeObjectOverrideOp,
2726
wrapDefaultObject,
2827
ObjectOverrideSetOp,
2928
} from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
3029
import Tooltip from 'rc-tooltip'
31-
import { Studios } from '../../../../collections'
30+
import { PeripheralDevices, Studios } from '../../../../collections'
3231
import { getHelpMode } from '../../../../lib/localStorage'
3332
import { useTracker } from '../../../../lib/ReactMeteorData/ReactMeteorData'
3433
import { TextInputControl } from '../../../../lib/Components/TextInput'
@@ -37,9 +36,8 @@ import { MeteorCall } from '../../../../lib/meteorApi'
3736

3837
interface StudioParentDevicesProps {
3938
studioId: StudioId
40-
studioDevices: PeripheralDevice[]
4139
}
42-
export function StudioParentDevices({ studioId, studioDevices }: Readonly<StudioParentDevicesProps>): JSX.Element {
40+
export function StudioParentDevices({ studioId }: Readonly<StudioParentDevicesProps>): JSX.Element {
4341
const { t } = useTranslation()
4442

4543
const studio = useTracker(() => Studios.findOne(studioId), [studioId])
@@ -75,11 +73,6 @@ export function StudioParentDevices({ studioId, studioDevices }: Readonly<Studio
7573
[deviceSettings]
7674
)
7775

78-
const filteredPeripheralDevices = useMemo(
79-
() => studioDevices.filter((d) => d.parentDeviceId === undefined),
80-
[studioDevices]
81-
)
82-
8376
const addNewItem = useCallback(() => {
8477
const newId = getRandomString()
8578
const newDevice = literal<StudioDeviceSettings>({
@@ -113,12 +106,7 @@ export function StudioParentDevices({ studioId, studioDevices }: Readonly<Studio
113106
</Tooltip>
114107
</h2>
115108

116-
<GenericParentDevicesTable
117-
studioId={studioId}
118-
devices={wrappedDeviceSettings}
119-
overrideHelper={overrideHelper}
120-
peripheralDevices={filteredPeripheralDevices}
121-
/>
109+
<GenericParentDevicesTable studioId={studioId} devices={wrappedDeviceSettings} overrideHelper={overrideHelper} />
122110

123111
<div className="mod mhs">
124112
<button className="btn btn-primary" onClick={addNewItem}>
@@ -140,21 +128,22 @@ interface ParentDevicesTableProps {
140128
studioId: StudioId
141129
devices: WrappedOverridableItem<StudioDeviceSettings>[]
142130
overrideHelper: OverrideOpHelper
143-
peripheralDevices: PeripheralDevice[]
144131
}
145132
function GenericParentDevicesTable({
146133
studioId,
147134
devices,
148135
overrideHelper,
149-
peripheralDevices,
150136
}: Readonly<ParentDevicesTableProps>): JSX.Element {
151137
const { t } = useTranslation()
152138
const { toggleExpanded, isExpanded } = useToggleExpandHelper()
153139

140+
const allParentDevices = useTracker(() => PeripheralDevices.find({ parentDeviceId: undefined }).fetch(), [], [])
141+
154142
const peripheralDevicesByConfigIdMap = useMemo(() => {
155143
const devicesMap = new Map<string, PeripheralDeviceTranslated>()
156144

157-
for (const device of peripheralDevices) {
145+
for (const device of allParentDevices) {
146+
if (device.studioId !== studioId) continue
158147
if (!device.configId) continue
159148

160149
devicesMap.set(
@@ -169,7 +158,7 @@ function GenericParentDevicesTable({
169158
}
170159

171160
return devicesMap
172-
}, [peripheralDevices])
161+
}, [studioId, allParentDevices])
173162

174163
const confirmRemove = useCallback(
175164
(parentdeviceId: string) => {
@@ -205,7 +194,7 @@ function GenericParentDevicesTable({
205194
},
206195
]
207196

208-
for (const device of peripheralDevices) {
197+
for (const device of allParentDevices) {
209198
options.push({
210199
value: device._id,
211200
name: device.name || unprotectString(device._id),
@@ -214,7 +203,7 @@ function GenericParentDevicesTable({
214203
}
215204

216205
return options
217-
}, [peripheralDevicesByConfigIdMap])
206+
}, [allParentDevices])
218207

219208
const undeleteItemWithId = useCallback(
220209
(itemId: string) => overrideHelper().resetItem(itemId).commit(),

packages/webui/src/client/ui/Settings/Studio/Devices/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function StudioDevices({ studioId }: Readonly<IStudioDevicesProps>): JSX.
2525
<>
2626
<StudioSelectDevices studioId={studioId} studioDevices={studioDevices} />
2727

28-
<StudioParentDevices studioId={studioId} studioDevices={studioDevices} />
28+
<StudioParentDevices studioId={studioId} />
2929

3030
<StudioPlayoutSubDevices studioId={studioId} studioDevices={studioDevices} />
3131

0 commit comments

Comments
 (0)