Skip to content

Commit

Permalink
wip: update to r50 - use peripheralDeviceForDevice instead of devices
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Mar 7, 2024
1 parent f2b47cb commit aeb8210
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/coreHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export class CoreHandler {
}
}
await this.core.init(ddpConfig)
this.logger.info('Core id: ' + this.core.deviceId)
await this.setupObserversAndSubscriptions()
this._statusInitialized = true
await this.updateCoreStatus()
Expand All @@ -110,10 +109,9 @@ export class CoreHandler {
this.logger.info('Core: Setting up subscriptions..')
this.logger.info('DeviceId: ' + this.core.deviceId)
await Promise.all([
this.core.autoSubscribe('peripheralDevices', [this.core.deviceId]),
this.core.autoSubscribe('peripheralDeviceForDevice', this.core.deviceId),
this.core.autoSubscribe('studios', [this.core.deviceId]),
this.core.autoSubscribe('peripheralDeviceCommands', this.core.deviceId),
// @todo: subscribe to userInput
])
this.logger.info('Core: Subscriptions are set up!')
if (this._observers.length) {
Expand All @@ -124,7 +122,7 @@ export class CoreHandler {
this._observers = []
}
// setup observers
const observer = this.core.observe('peripheralDevices')
const observer = this.core.observe('peripheralDeviceForDevice')
observer.added = (id: string) => {
this.onDeviceChanged(protectString(id))
}
Expand Down
12 changes: 9 additions & 3 deletions src/spreadsheetHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CoreHandler } from './coreHandler'
import { RunningOrderWatcher } from './classes/RunningOrderWatcher'
import { mutateRundown, mutateSegment, mutatePart } from './mutate'
import { PeripheralDeviceForDevice } from '@sofie-automation/server-core-integration'
import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SpreadsheetConfig {
Expand Down Expand Up @@ -39,6 +40,7 @@ export interface Credentials {
redirect_uris: string[]
}
}

export interface AccessToken {
access_token: string
refresh_token: string
Expand All @@ -47,7 +49,10 @@ export interface AccessToken {
expiry_date: number
}

const ACCESS_SCOPES = ['https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/spreadsheets']
const ACCESS_SCOPES = [
'https://www.googleapis.com/auth/documents.readonly',
'https://www.googleapis.com/auth/spreadsheets',
]

export class SpreadsheetHandler {
public options: SpreadsheetConfig
Expand Down Expand Up @@ -198,8 +203,9 @@ export class SpreadsheetHandler {
this._logger.info('Initializing Spreadsheet connection...')
}
private getThisPeripheralDevice(): PeripheralDeviceForDevice | undefined {
const peripheralDevices = this._coreHandler.core.getCollection('peripheralDevicesForDevice')
return peripheralDevices.findOne(this._coreHandler.core.deviceId as never)
const peripheralDevices = this._coreHandler.core.getCollection('peripheralDeviceForDevice')
const device = peripheralDevices.findOne(protectString(String(this._coreHandler.core.deviceId)))
return device
}
private async _updateDevices(): Promise<void> {
if (this._disposed) return Promise.resolve()
Expand Down

0 comments on commit aeb8210

Please sign in to comment.