Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions client-v3/src/stores/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
import log from 'loglevel';
import { makeURL } from '@/js/utils';
import { toast } from '@/js/toast';
import { useScriptConfigStore } from '@/stores/scriptConfig';
import type {
ScriptLine,
StageDirectionStyle,
Expand Down Expand Up @@ -47,6 +48,17 @@ export const useScriptStore = defineStore('script', {
}
},

async scriptPageChanged(data: { page: number }): Promise<void> {
const pageStr = String(data.page);
if (Object.hasOwn(this.script, pageStr)) {
await this.loadScriptPage(data.page);
const scriptConfigStore = useScriptConfigStore();
if (Object.hasOwn(scriptConfigStore.tmpScript, pageStr)) {
scriptConfigStore.addPage(data.page, this.getScriptPage(data.page));
}
}
},

async saveNewPage(page: number, lines: ScriptLine[]): Promise<boolean> {
const params = new URLSearchParams({ page: String(page) });
const response = await fetch(`${makeURL('/api/v1/show/script')}?${params}`, {
Expand Down
7 changes: 7 additions & 0 deletions client/src/store/modules/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ const module: Module<ScriptState, RootState> = {
await context.dispatch('LOAD_CUES');
await context.dispatch('GET_CUTS');
},
async SCRIPT_PAGE_CHANGED(context, msg: { DATA: { page: number } }) {
const page = String(msg.DATA.page);
if (Object.hasOwn(context.state.script, page)) {
await context.dispatch('LOAD_SCRIPT_PAGE', page);
await context.dispatch('ADD_BLANK_PAGE', page);
}
},
async LOAD_SCRIPT_PAGE(context, page: string | number) {
const searchParams = new URLSearchParams({ page: String(page) });
const response = await fetch(`${makeURL('/api/v1/show/script')}?${searchParams}`, {
Expand Down
7 changes: 7 additions & 0 deletions server/controllers/api/show/script/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ async def post(self):
CompiledScript.compile_script, self.application, revision.id
)
)
await self.application.ws_send_to_all(
"NOOP", "SCRIPT_PAGE_CHANGED", {"page": page}
)
else:
self.set_status(404)
await self.finish({"message": ERROR_SHOW_NOT_FOUND})
Expand Down Expand Up @@ -663,11 +666,15 @@ async def patch(self):
(revision.id, line["id"]),
)
# Spawn a callback to create a compiled version of the script
session.commit()
IOLoop.current().add_callback(
partial(
CompiledScript.compile_script, self.application, revision.id
)
)
await self.application.ws_send_to_all(
"NOOP", "SCRIPT_PAGE_CHANGED", {"page": page}
)
else:
self.set_status(404)
await self.finish({"message": ERROR_SHOW_NOT_FOUND})
Expand Down
Loading