Skip to content

Commit

Permalink
refactor(NodeService): Clean up getNextNode() for AT/CM modes (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima authored Oct 8, 2023
1 parent c6ecce6 commit 697fc68
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/assets/wise5/services/nodeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,19 @@ export class NodeService {
* @param currentId (optional)
* @returns a promise that returns the next node id
*/
getNextNodeId(currentId?): Promise<any> {
getNextNodeId(currentId?: string): Promise<any> {
const promise = new Promise((resolve, reject) => {
let nextNodeId = null;
let currentNodeId = null;
let mode = this.ConfigService.getMode();
if (currentId) {
currentNodeId = currentId;
} else {
let currentNode = null;
currentNode = this.DataService.getCurrentNode();
if (currentNode) {
currentNodeId = currentNode.id;
}
}
const currentNodeId = currentId ?? this.DataService.getCurrentNodeId();
if (currentNodeId) {
if (mode === 'classroomMonitor' || mode === 'author') {
let currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId);
if (['author', 'classroomMonitor'].includes(this.ConfigService.getMode())) {
const currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId);
if (currentNodeOrder) {
let nextNodeOrder = currentNodeOrder + 1;
let nextId = this.ProjectService.getNodeIdByOrder(nextNodeOrder);
const nextId = this.ProjectService.getNodeIdByOrder(currentNodeOrder + 1);
if (nextId) {
if (this.ProjectService.isApplicationNode(nextId)) {
nextNodeId = nextId;
} else if (this.ProjectService.isGroupNode(nextId)) {
nextNodeId = this.getNextNodeId(nextId);
}
nextNodeId = this.ProjectService.isApplicationNode(nextId)
? nextId
: this.getNextNodeId(nextId);
}
}
resolve(nextNodeId);
Expand Down

0 comments on commit 697fc68

Please sign in to comment.