Skip to content

Commit df966af

Browse files
author
Simon Rogers
committed
Update from PR feedback, use existing studio properties where available when upgrading through API
1 parent fceb513 commit df966af

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

meteor/server/api/rest/v1/studios.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,15 @@ class StudiosServerAPI implements StudiosRestAPI {
101101

102102
await Studios.upsertAsync(studioId, newStudio)
103103

104-
// wait for the upsert to complete before validation and upgrade read from the studios collection
105-
await new Promise<void>((resolve) => setTimeout(() => resolve(), 200))
106-
107104
const validation = await validateConfigForStudio(studioId)
108105
checkValidation(`addOrUpdateStudio ${studioId}`, validation.messages)
109106

110-
return ClientAPI.responseSuccess(
111-
await new Promise<string | false>((resolve) =>
112-
// wait for the upsert to complete before upgrade
113-
setTimeout(async () => {
114-
await runUpgradeForStudio(studioId)
115-
resolve(await updateStudioBaseline(studioId))
116-
}, 200)
117-
)
118-
)
107+
// wait for the upsert to complete before upgrade
108+
await new Promise<void>((resolve) => setTimeout(() => resolve(), 200))
109+
110+
await runUpgradeForStudio(studioId)
111+
112+
return ClientAPI.responseSuccess(await updateStudioBaseline(studioId))
119113
}
120114

121115
async getStudioConfig(
@@ -151,21 +145,15 @@ class StudiosServerAPI implements StudiosRestAPI {
151145

152146
await Studios.upsertAsync(studioId, newStudio)
153147

154-
// wait for the upsert to complete before validation and upgrade read from the studios collection
155-
await new Promise<void>((resolve) => setTimeout(() => resolve(), 200))
156-
157148
const validation = await validateConfigForStudio(studioId)
158149
checkValidation(`updateStudioConfig ${studioId}`, validation.messages)
159150

160-
return ClientAPI.responseSuccess(
161-
await new Promise<string | false>((resolve) =>
162-
// wait for the upsert to complete before upgrade
163-
setTimeout(async () => {
164-
await runUpgradeForStudio(studioId)
165-
resolve(await updateStudioBaseline(studioId))
166-
}, 200)
167-
)
168-
)
151+
// wait for the upsert to complete before upgrade
152+
await new Promise<void>((resolve) => setTimeout(() => resolve(), 200))
153+
154+
await runUpgradeForStudio(studioId)
155+
156+
return ClientAPI.responseSuccess(await updateStudioBaseline(studioId))
169157
}
170158

171159
async deleteStudio(

meteor/server/api/rest/v1/typeConversion.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,15 @@ export async function studioFrom(apiStudio: APIStudio, existingId?: StudioId): P
341341
: wrapDefaultObject(studioSettings),
342342
supportedShowStyleBase: apiStudio.supportedShowStyleBase?.map((id) => protectString<ShowStyleBaseId>(id)) ?? [],
343343
organizationId: null,
344-
mappingsWithOverrides: wrapDefaultObject({}),
345-
routeSetsWithOverrides: wrapDefaultObject({}),
344+
mappingsWithOverrides: studio?.mappingsWithOverrides ?? wrapDefaultObject({}),
345+
mappingsHash: studio?.mappingsHash,
346+
routeSetsWithOverrides: studio?.routeSetsWithOverrides ?? wrapDefaultObject({}),
346347
_rundownVersionHash: studio?._rundownVersionHash ?? '',
347348
routeSetExclusivityGroupsWithOverrides: wrapDefaultObject({}),
348349
packageContainersWithOverrides: wrapDefaultObject({}),
349350
previewContainerIds: [],
350351
thumbnailContainerIds: [],
351-
peripheralDeviceSettings: {
352+
peripheralDeviceSettings: studio?.peripheralDeviceSettings ?? {
352353
deviceSettings: wrapDefaultObject({}),
353354
playoutDevices: wrapDefaultObject({}),
354355
ingestDevices: wrapDefaultObject({}),

0 commit comments

Comments
 (0)