Skip to content

Commit 4d06e30

Browse files
committed
chore: fix type mismatch for NotificationTargetTypes
1 parent 3fd48ee commit 4d06e30

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

packages/live-status-gateway/src/topics/helpers/notification/notificationTarget/toNotificationTarget.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,25 @@ export function toNotificationTarget(dbTarget: DBNotificationTarget): Notificati
3838
}
3939
}
4040

41-
function toNotificationTargetBase(dbTarget: DBNotificationTarget): Pick<NotificationTarget, 'type' | 'studioId'> {
42-
return literal<Pick<NotificationTarget, 'type' | 'studioId'>>({
43-
type: toNotificationTargetType(dbTarget.type),
41+
function toNotificationTargetBase(dbTarget: DBNotificationTarget): Pick<NotificationTarget, 'studioId'> {
42+
return literal<Pick<NotificationTarget, 'studioId'>>({
4443
studioId: unprotectString(dbTarget.studioId),
4544
})
4645
}
4746

48-
function toNotificationTargetType(dbTargetType: DBNotificationTargetType): NotificationTargetType {
49-
switch (dbTargetType) {
50-
case DBNotificationTargetType.PARTINSTANCE:
51-
return NotificationTargetType.PART_INSTANCE
52-
case DBNotificationTargetType.PIECEINSTANCE:
53-
return NotificationTargetType.PART_INSTANCE
54-
case DBNotificationTargetType.RUNDOWN:
55-
return NotificationTargetType.RUNDOWN
56-
case DBNotificationTargetType.PLAYLIST:
57-
return NotificationTargetType.PLAYLIST
58-
}
59-
}
60-
6147
function toNotificationTargetRundown(dbTarget: DBNotificationTargetRundown): NotificationTargetRundown {
6248
return literal<NotificationTargetRundown>({
6349
...toNotificationTargetBase(dbTarget),
50+
type: NotificationTargetType.RUNDOWN,
6451
rundownId: unprotectString(dbTarget.rundownId),
6552
})
6653
}
6754

6855
function toNotificationTargetPartInstance(dbTarget: DBNotificationTargetPartInstance): NotificationTargetPartInstance {
6956
return literal<NotificationTargetPartInstance>({
70-
...toNotificationTargetRundown({
71-
type: DBNotificationTargetType.RUNDOWN,
72-
studioId: dbTarget.studioId,
73-
rundownId: dbTarget.rundownId,
74-
}),
57+
...toNotificationTargetBase(dbTarget),
7558
type: NotificationTargetType.PART_INSTANCE,
59+
rundownId: unprotectString(dbTarget.rundownId),
7660
partInstanceId: unprotectString(dbTarget.partInstanceId),
7761
})
7862
}
@@ -81,13 +65,10 @@ function toNotificationTargetPieceInstance(
8165
dbTarget: DBNotificationTargetPieceInstance
8266
): NotificationTargetPieceInstance {
8367
return literal<NotificationTargetPieceInstance>({
84-
...toNotificationTargetPartInstance({
85-
type: DBNotificationTargetType.PARTINSTANCE,
86-
studioId: dbTarget.studioId,
87-
rundownId: dbTarget.rundownId,
88-
partInstanceId: dbTarget.partInstanceId,
89-
}),
68+
...toNotificationTargetBase(dbTarget),
9069
type: NotificationTargetType.PIECE_INSTANCE,
70+
rundownId: unprotectString(dbTarget.rundownId),
71+
partInstanceId: unprotectString(dbTarget.partInstanceId),
9172
pieceInstanceId: unprotectString(dbTarget.pieceInstanceId),
9273
})
9374
}
@@ -97,6 +78,7 @@ function toNotificationTargetPlaylist(
9778
): NotificationTargetRundownPlaylist {
9879
return literal<NotificationTargetRundownPlaylist>({
9980
...toNotificationTargetBase(dbTarget),
81+
type: NotificationTargetType.PLAYLIST,
10082
playlistId: unprotectString(dbTarget.playlistId),
10183
})
10284
}

0 commit comments

Comments
 (0)