Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 25, 2024
1 parent 17b0fdb commit b2b421d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ export class PartTransformer {

private readonly corePartPieces = observable.map<Core.PartId, Core.Piece[]>()

private readonly editedScripts = observable.map<Core.PartId, ScriptContents>()

constructor(private transformers: Transformers) {
makeObservable(this, {
partIds: computed,
updateEditedScript: action,
updateCorePart: action,
updateCorePiece: action,
updateCoreShowStyleBase: action,
Expand Down Expand Up @@ -159,6 +162,8 @@ export class PartTransformer {
}
}

const editedScript = this.editedScripts.get(this.convertId(partId))

return literal<Part>({
_id: partId,
playlistId,
Expand All @@ -180,11 +185,18 @@ export class PartTransformer {
label: derived.displayLabel,
},
scriptContents: derived.scriptContents,
editedScriptContents: editedScript,
})

return undefined
})

updateEditedScript(partId: Core.PartId, editedScript: ScriptContents | undefined) {
if (editedScript !== undefined) {
this.editedScripts.set(partId, editedScript)
} else {
this.editedScripts.delete(partId)
}
}

updateCorePart(partId: Core.PartId, part: Core.DBPart | undefined) {
if (part) {
if (!isEqual(this.coreParts.get(partId), part)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function makeNewEditorState(doc: Node): EditorState {
keymap(formatingKeymap),
keymap(baseKeymap),
readOnlyNodeFilter(),
updateModel((lineId, change) => console.log(lineId, change)),
updateModel((lineId, change) => console.log(lineId, change, doc)),
],
doc,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/client/src/model/UILine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class UILine {
this.identifier = json.identifier ?? null
this.slug = json.label
this.rank = json.rank
this.script = json.scriptContents ?? null
this.script = json.editedScriptContents ?? json.scriptContents ?? null
this.isNew = json.isNew ?? false
this.expectedDuration = json.expectedDuration ?? null
this.lineType = {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/model/src/model/Part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface Part extends DataObject {
}

scriptContents?: ScriptContents
editedScriptContents?: ScriptContents
}

export enum PartDisplayType {
Expand Down

0 comments on commit b2b421d

Please sign in to comment.