aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormadelinegr <mgriswold99@gmail.com>2019-06-13 11:43:21 -0400
committermadelinegr <mgriswold99@gmail.com>2019-06-13 11:43:21 -0400
commit7de0db8000aab06ccc8f973a50734cfdee93a388 (patch)
treed956a53bf2a61ee720ddb0c22ae61d8d7a27634d
parent5c60cd95b3f766a18dee95ead388dd9f9603d138 (diff)
Documentation for saving and loading presentation state
-rw-r--r--src/client/views/presentationview/PresentationElement.tsx16
-rw-r--r--src/client/views/presentationview/PresentationView.tsx31
2 files changed, 24 insertions, 23 deletions
diff --git a/src/client/views/presentationview/PresentationElement.tsx b/src/client/views/presentationview/PresentationElement.tsx
index 53e6f903b..c58570798 100644
--- a/src/client/views/presentationview/PresentationElement.tsx
+++ b/src/client/views/presentationview/PresentationElement.tsx
@@ -66,14 +66,15 @@ export default class PresentationElement extends React.Component<PresentationEle
}
async componentDidMount() {
- // let castedList = Cast(this.props.presButtonBackUp.selectedButtons, listSpec(Doc), null) as any as List<List<boolean>>;
+ //get the list that stores docs that keep track of buttons
let castedList = Cast(this.props.presButtonBackUp.selectedButtonDocs, listSpec(Doc));
if (!castedList) {
this.props.presButtonBackUp.selectedButtonDocs = castedList = new List<Doc>();
}
-
+ //if this is the first time this doc mounts, push a doc for it to store
if (castedList.length <= this.props.index) {
castedList.push(new Doc());
+ //otherwise update the selected buttons depending on storage.
} else {
let curDoc: Doc = await castedList[this.props.index];
let selectedButtonOfDoc = Cast(curDoc.selectedButtons, listSpec("boolean"), null);
@@ -164,14 +165,20 @@ export default class PresentationElement extends React.Component<PresentationEle
}
+ /**
+ * This function is called at the end of each group update to update the group updates.
+ */
@action
autoSaveGroupChanges = () => {
let castedList: List<Doc> = new List<Doc>();
this.props.presGroupBackUp.groupDocs = castedList;
this.props.groupMappings.forEach((docArray: Doc[], id: String) => {
+ //create a new doc for each group
let newGroupDoc = new Doc();
castedList.push(newGroupDoc);
+ //store the id of the group in the doc
newGroupDoc.presentIdStore = id.toString();
+ //store the doc array which represents the group in the doc
newGroupDoc.grouping = new List(docArray);
});
@@ -215,13 +222,14 @@ export default class PresentationElement extends React.Component<PresentationEle
this.autoSaveButtonChange(buttonIndex.HideTillPressed);
}
+ /**
+ * This function is called to get the updates for the changed buttons.
+ */
@action
autoSaveButtonChange = async (index: buttonIndex) => {
- // let castedList = Cast(this.props.presButtonBackUp.selectedButtons, listSpec(Doc), null) as any as List<List<boolean>>;
let castedList = (await DocListCastAsync(this.props.presButtonBackUp.selectedButtonDocs))!;
castedList[this.props.index].selectedButtons = new List(this.selectedButtons);
- //this.props.mainDocument.presButtonBackUp = this.props.presButtonBackUp;
}
/**
diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx
index 0ba14e8ab..d3365725b 100644
--- a/src/client/views/presentationview/PresentationView.tsx
+++ b/src/client/views/presentationview/PresentationView.tsx
@@ -55,6 +55,7 @@ class PresentationViewList extends React.Component<PresListProps> {
//checking if part of group
let storedGuids: string[] = [];
let castedGroupDocs = await DocListCastAsync(this.props.presGroupBackUp.groupDocs);
+ //making sure the docs that were in groups, which were stored, to not get new guids.
if (castedGroupDocs !== undefined) {
castedGroupDocs.forEach((doc: Doc) => {
let storedGuid = StrCast(doc.presentIdStore, null);
@@ -70,26 +71,10 @@ class PresentationViewList extends React.Component<PresListProps> {
});
}
- @action
- initializeSelectedButtonDocs = (docList: Doc[]) => {
-
- let castedList = DocListCast(this.props.presButtonBackUp.selectedButtonDocs);
- if (castedList.length === 0) {
- let newDocArray: List<Doc> = new List();
- newDocArray.push(new Doc());
- this.props.presButtonBackUp.selectedButtonDocs = newDocArray;
- } else {
- castedList.push(new Doc());
- }
-
-
- }
-
render() {
const children = DocListCast(this.props.Document.data);
this.initializeGroupIds(children);
this.props.setChildrenDocs(children);
- //this.initializeSelectedButtonDocs(children);
return (
<div className="presentationView-listCont">
@@ -119,10 +104,10 @@ export class PresentationView extends React.Component<PresViewProps> {
componentDidMount() {
- // let newDoc = new Doc();
- // let newDoc2 = new Doc();
+ //getting both backUp documents
let castedGroupBackUp = Cast(this.props.Document.presGroupBackUp, Doc);
let castedButtonBackUp = Cast(this.props.Document.presButtonBackUp, Doc);
+ //if instantiated before
if (castedGroupBackUp instanceof Promise) {
castedGroupBackUp.then(doc => {
let toAssign = doc ? doc : new Doc();
@@ -134,6 +119,7 @@ export class PresentationView extends React.Component<PresViewProps> {
}
}
});
+ //if never instantiated a store doc yet
} else {
runInAction(() => {
let toAssign = new Doc();
@@ -143,6 +129,7 @@ export class PresentationView extends React.Component<PresViewProps> {
});
}
+ //if instantiated before
if (castedButtonBackUp instanceof Promise) {
castedButtonBackUp.then(doc => {
@@ -151,6 +138,7 @@ export class PresentationView extends React.Component<PresViewProps> {
runInAction(() => this.presButtonBackUp = toAssign);
});
+ //if never instantiated a store doc yet
} else {
runInAction(() => {
let toAssign = new Doc();
@@ -160,12 +148,17 @@ export class PresentationView extends React.Component<PresViewProps> {
}
+
+ //storing the presentation status,ie. whether it was stopped or playing
let presStatusBackUp = BoolCast(this.props.Document.presStatus, null);
runInAction(() => this.presStatus = presStatusBackUp);
}
+ /**
+ * This is the function that is called to retrieve the groups that have been stored and
+ * push them to the groupMappings.
+ */
retrieveGroupMappings = async () => {
- //runInAction(() => this.groupMappings = new Map());
let castedGroupDocs = await DocListCastAsync(this.presGroupBackUp.groupDocs);
if (castedGroupDocs !== undefined) {
castedGroupDocs.forEach(async (groupDoc: Doc, index: number) => {