Skip to content

Commit

Permalink
refactor: undo/redo with browser compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ianshade committed Oct 31, 2023
1 parent 61ab142 commit 5c8e3bb
Show file tree
Hide file tree
Showing 24 changed files with 395 additions and 201 deletions.
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"deepmerge-ts": "^5.1.0",
"electron-is-dev": "^2.0.0",
"electron-updater": "^5.3.0",
"eventemitter3": "^5.0.1",
"file-loader": "^6.2.0",
"formik": "^2.2.9",
"formik-mui": "^5.0.0-alpha.0",
Expand Down
15 changes: 13 additions & 2 deletions apps/app/src/electron/ClientEventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ import { ActiveAnalog } from '../models/rundown/Analog'
import { AnalogInput } from '../models/project/AnalogInput'
import { BridgeId } from '@shared/api'
import { BridgePeripheralId } from '@shared/lib'
import { EventEmitter } from 'stream'
import EventEmitter from 'eventemitter3'
import { SerializableLedgers } from '../models/project/Project'

type ClientEventBusEvents = {
callMethod: (...args: any[]) => void // legacy
updateUndoLedgers: (undoLedgers: SerializableLedgers) => void
updateRundown: (rundown: Rundown) => void
updateProject: (rundown: Project) => void
}

// --- some of it might be needed, most of it hopefully not
export class ClientEventBus extends EventEmitter implements IPCClientMethods {
export class ClientEventBus extends EventEmitter<ClientEventBusEvents> implements IPCClientMethods {
close(): void {
// Nothing here
}
Expand All @@ -31,6 +39,9 @@ export class ClientEventBus extends EventEmitter implements IPCClientMethods {
updateRundown(_fileName: string, rundown: Rundown): void {
this.emit('updateRundown', rundown) // TODO: some type safety, please
}
updateUndoLedgers(data: SerializableLedgers): void {
this.emit('updateUndoLedgers', data) // TODO: some type safety, please
}
updateResourcesAndMetadata(
resources: Array<{ id: ResourceId; resource: ResourceAny | null }>,
metadata: SerializedProtectedMap<TSRDeviceId, MetadataAny | null>
Expand Down
Loading

0 comments on commit 5c8e3bb

Please sign in to comment.