Skip to content

Commit

Permalink
chore: merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Jan 18, 2024
1 parent 9c6f3c2 commit 8e4ad90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions packages/apps/client/src/Output/Output.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import React, { useEffect, useMemo, useReducer, useRef } from 'react'
import { observer } from 'mobx-react-lite'
import { AppStore } from '../stores/AppStore'
import { RootAppStore } from '../stores/RootAppStore.ts'

const Output = observer(function Output() {
const speed = useRef(0)

// On startup
useEffect(() => {
AppStore.outputSettingsStore.initialize() // load and subscribe
RootAppStore.outputSettingsStore.initialize() // load and subscribe

AppStore.connection.controller.on('message', (message) => {
RootAppStore.connection.controller.on('message', (message) => {
console.log('received message', message)

speed.current = message.speed
})
AppStore.connection.controller.subscribeToMessages().catch(console.error)
RootAppStore.connection.controller.subscribeToMessages().catch(console.error)

// don't do this, it's just for testing:
const interval = setInterval(() => {
window.scrollBy(0, speed.current)
}, 1000 / 60)
return () => {
AppStore.connection.controller.off('message')
RootAppStore.connection.controller.off('message')
clearInterval(interval)
}
}, [])

const outputSettings = AppStore.outputSettingsStore.outputSettings
const outputSettings = RootAppStore.outputSettingsStore.outputSettings

const activeRundownPlaylistId = outputSettings?.activeRundownPlaylistId

useEffect(() => {
if (activeRundownPlaylistId) {
AppStore.rundownStore.loadRundown(activeRundownPlaylistId)
RootAppStore.rundownStore.loadRundown(activeRundownPlaylistId)
} else {
// TODO: unload rundown?
}
}, [activeRundownPlaylistId])

const rundown = AppStore.rundownStore.openRundown
const rundown = RootAppStore.rundownStore.openRundown

/*
Implementation notes:
Expand Down Expand Up @@ -111,7 +111,7 @@ const Output = observer(function Output() {
return (
<>
<h1>Prompter output</h1>
<div>Initialized: {AppStore.outputSettingsStore.initialized ? 'YES' : 'NO'}</div>
<div>Initialized: {RootAppStore.outputSettingsStore.initialized ? 'YES' : 'NO'}</div>
<div>{JSON.stringify(outputSettings)}</div>

<div>{rundown ? <>Rundown: {rundown.name}</> : <>No active rundown</>}</div>
Expand Down
10 changes: 5 additions & 5 deletions packages/apps/client/src/TestController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { observer } from 'mobx-react-lite'
import { APIConnection } from './api/ApiConnection.ts'
import { OutputSettings } from '@sofie-prompter-editor/shared-model'
import { EditObject, useApiConnection } from './TestUtil.tsx'
import { AppStore } from './stores/AppStore.ts'
import { RootAppStore } from './stores/RootAppStore.ts'
import { computed } from 'mobx'

const TestController: React.FC = observer(() => {
Expand All @@ -13,9 +13,9 @@ const TestController: React.FC = observer(() => {

// On startup
useEffect(() => {
AppStore.outputSettingsStore.initialize() // load and subscribe
RootAppStore.outputSettingsStore.initialize() // load and subscribe
}, [])
const outputSettings = computed(() => AppStore.outputSettingsStore.outputSettings).get()
const outputSettings = computed(() => RootAppStore.outputSettingsStore.outputSettings).get()

console.log('outputSettings', outputSettings)

Expand Down Expand Up @@ -73,7 +73,7 @@ const TestController: React.FC = observer(() => {
// )

const sendSpeed = useCallback((speed: number) => {
AppStore.connection.controller
RootAppStore.connection.controller
.sendMessage({
offset: null,
speed: speed,
Expand All @@ -92,7 +92,7 @@ const TestController: React.FC = observer(() => {
obj={outputSettings}
onChange={(newData) => {
// console.log('newdata', newData)
AppStore.connection.outputSettings.update(null, newData).catch(console.error)
RootAppStore.connection.outputSettings.update(null, newData).catch(console.error)
}}
/>
) : (
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/client/src/stores/OutputSettingsStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { observable, action, flow, makeObservable, IReactionDisposer, reaction } from 'mobx'
import { OutputSettings } from '@sofie-prompter-editor/shared-model'
import { APIConnection, AppStore } from './AppStore'
import { APIConnection, RootAppStore } from './RootAppStore.ts'

export class OutputSettingsStore {
// showingOnlyScripts = false
Expand All @@ -15,7 +15,7 @@ export class OutputSettingsStore {

reactions: IReactionDisposer[] = []

constructor(public appStore: typeof AppStore, public connection: APIConnection) {
constructor(public appStore: typeof RootAppStore, public connection: APIConnection) {
makeObservable(this, {
outputSettings: observable,
initialized: observable,
Expand Down

0 comments on commit 8e4ad90

Please sign in to comment.