Skip to content

Commit

Permalink
Fix for choice tags not being serialised
Browse files Browse the repository at this point in the history
  • Loading branch information
smwhr committed Aug 3, 2024
1 parent 90d7a41 commit caa804e
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/engine/JsonSerialisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,16 @@ export class JsonSerialisation {
choice.sourcePath = jObj["originalChoicePath"].toString();
choice.originalThreadIndex = parseInt(jObj["originalThreadIndex"]);
choice.pathStringOnChoice = jObj["targetPath"].toString();
choice.tags = this.JArrayToTags(jObj);
return choice;
}

public static JArrayToTags(jObj: Record<string, any>) {
if (jObj["tags"]) {
choice.tags = jObj["tags"];
return jObj["tags"];
} else {
return null;
}
return choice;
}

public static WriteChoice(writer: SimpleJson.Writer, choice: Choice) {
Expand All @@ -593,20 +599,22 @@ export class JsonSerialisation {
writer.WriteProperty("originalChoicePath", choice.sourcePath);
writer.WriteIntProperty("originalThreadIndex", choice.originalThreadIndex);
writer.WriteProperty("targetPath", choice.pathStringOnChoice);
if (choice.tags) {
writer.WriteProperty("tags", (w) => {
w.WriteArrayStart();
for (const tag of choice.tags!) {
w.WriteStringStart();
w.WriteStringInner(tag);
w.WriteStringEnd();
}
w.WriteArrayEnd();
});
}
this.WriteChoiceTags(writer, choice);
writer.WriteObjectEnd();
}

public static WriteChoiceTags(writer: SimpleJson.Writer, choice: Choice) {
if (choice.tags && choice.tags.length > 0) {
writer.WritePropertyStart("tags");
writer.WriteArrayStart();
for (const tag of choice.tags!) {
writer.Write(tag);
}
writer.WriteArrayEnd();
writer.WritePropertyEnd();
}
}

public static WriteInkList(writer: SimpleJson.Writer, listVal: ListValue) {
let rawList = listVal.value;
if (rawList === null) {
Expand Down

0 comments on commit caa804e

Please sign in to comment.