Skip to content

Commit

Permalink
chore: enums
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Oct 18, 2023
1 parent 7bb4c61 commit e5e1733
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apps/app/src/electron/api/ApiServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RundownService, RUNDOWN_CHANNEL_PREFIX } from './RundownService'
import { LegacyService } from './LegacyService'
import { ReportingService } from './ReportingService'
import { PROJECTS_CHANNEL_PREFIX, ProjectService } from './ProjectService'
import { ClientMethods, ServiceName, ServiceTypes } from '../../ipc/IPCAPI'
import { ClientMethods, ProjectsEvents, RundownsEvents, ServiceName, ServiceTypes } from '../../ipc/IPCAPI'
import { Project, ProjectBase } from '../../models/project/Project'
import { PartService } from './PartService'
import { GroupService } from './GroupService'
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ApiServer {

this.app.use(ServiceName.PROJECTS, new ProjectService(this.app, ipcServer, clientEventBus), {
methods: ClientMethods[ServiceName.PROJECTS],
serviceEvents: ['created', 'updated', 'deleted'],
serviceEvents: ['created', ProjectsEvents.UPDATED, 'deleted'],
})

this.app.use(ServiceName.PARTS, new PartService(this.app, ipcServer, clientEventBus), {
Expand All @@ -52,7 +52,7 @@ export class ApiServer {
this.app.use(ServiceName.RUNDOWNS, new RundownService(this.app, ipcServer, clientEventBus), {
// TODO: what if we made a base class for Services and made those arrays fields so that they live nearvy the implementation?
methods: ClientMethods[ServiceName.RUNDOWNS],
serviceEvents: ['created', 'updated', 'deleted'],
serviceEvents: ['created', RundownsEvents.UPDATED, 'deleted'],
})

this.app.use(ServiceName.REPORTING, new ReportingService(this.app, ipcServer), {
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/electron/api/ProjectService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EverythingService } from '../EverythingService'
import { Application, Params } from '@feathersjs/feathers'
import EventEmitter from 'node:events'
import { ServiceTypes } from '../../ipc/IPCAPI'
import { ProjectsEvents, ServiceTypes } from '../../ipc/IPCAPI'
import { Project, ProjectBase } from '../../models/project/Project'
import { ClientEventBus } from '../ClientEventBus'

Expand All @@ -14,7 +14,7 @@ export class ProjectService extends EventEmitter {
) {
super()
clientEventBus.on('updateProject', (project: Project) => {
this.emit('updated', project)
this.emit(ProjectsEvents.UPDATED, project)
})
}

Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/electron/api/RundownService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Application, Params } from '@feathersjs/feathers'
import { Rundown } from '../../models/rundown/Rundown'
import EventEmitter from 'node:events'
import { GeneralError, NotFound } from '@feathersjs/errors'
import { ServiceTypes } from '../../ipc/IPCAPI'
import { RundownsEvents, ServiceTypes } from '../../ipc/IPCAPI'
import { PartialDeep } from 'type-fest/source/partial-deep'
import { TimelineObj } from '../../models/rundown/TimelineObj'
import { ClientEventBus } from '../ClientEventBus'
Expand Down Expand Up @@ -34,7 +34,7 @@ export class RundownService extends EventEmitter {
) {
super()
clientEventBus.on('updateRundown', (rundown: Rundown) => {
this.emit('updated', rundown)
this.emit(RundownsEvents.UPDATED, rundown)
})
}

Expand Down
7 changes: 7 additions & 0 deletions apps/app/src/ipc/IPCAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,10 @@ export interface SystemMessageOptions {
displayRestartButton?: boolean
}
export type UpdateAppDataOptions = Pick<AppData, 'preReleaseAutoUpdate' | 'guiDecimalCount'>

export enum RundownsEvents {
UPDATED = 'updated',
}
export enum ProjectsEvents {
UPDATED = 'updated',
}
8 changes: 5 additions & 3 deletions apps/app/src/react/api/RealtimeDataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServiceName, SystemMessageOptions } from '../../ipc/IPCAPI'
import { ProjectsEvents, RundownsEvents, ServiceName, SystemMessageOptions } from '../../ipc/IPCAPI'
import { BridgeStatus } from '../../models/project/Bridge'
import { Project } from '../../models/project/Project'
import { PeripheralStatus } from '../../models/project/Peripheral'
Expand Down Expand Up @@ -40,8 +40,10 @@ export class RealtimeDataProvider {
}
) {
// this is new:
app.service(ServiceName.RUNDOWNS).on('updated', (rundown) => this.updateRundown(rundown.id, rundown))
app.service(ServiceName.PROJECTS).on('updated', (project) => this.updateProject(project))
app.service(ServiceName.RUNDOWNS).on(RundownsEvents.UPDATED, (rundown) =>
this.updateRundown(rundown.id, rundown)
)
app.service(ServiceName.PROJECTS).on(ProjectsEvents.UPDATED, (project) => this.updateProject(project))
// app.service('project').on(...) etc.

// this is temporary:
Expand Down

0 comments on commit e5e1733

Please sign in to comment.