(action: LayoutActionData)
| 433 | } |
| 434 | |
| 435 | private async handleBackendAction(action: LayoutActionData) { |
| 436 | switch (action.actiontype) { |
| 437 | case LayoutTreeActionType.InsertNode: { |
| 438 | if (action.ephemeral) { |
| 439 | this.newEphemeralNode(action.blockid); |
| 440 | break; |
| 441 | } |
| 442 | const insertNodeAction: LayoutTreeInsertNodeAction = { |
| 443 | type: LayoutTreeActionType.InsertNode, |
| 444 | node: newLayoutNode(undefined, undefined, undefined, { |
| 445 | blockId: action.blockid, |
| 446 | }), |
| 447 | magnified: action.magnified, |
| 448 | focused: action.focused, |
| 449 | }; |
| 450 | this.treeReducer(insertNodeAction, false); |
| 451 | break; |
| 452 | } |
| 453 | case LayoutTreeActionType.DeleteNode: { |
| 454 | const leaf = this?.getNodeByBlockId(action.blockid); |
| 455 | if (leaf) { |
| 456 | await this.closeNode(leaf.id); |
| 457 | } else { |
| 458 | console.error( |
| 459 | "Cannot apply eventbus layout action DeleteNode, could not find leaf node with blockId", |
| 460 | action.blockid |
| 461 | ); |
| 462 | } |
| 463 | break; |
| 464 | } |
| 465 | case LayoutTreeActionType.InsertNodeAtIndex: { |
| 466 | if (!action.indexarr) { |
| 467 | console.error("Cannot apply eventbus layout action InsertNodeAtIndex, indexarr field is missing."); |
| 468 | break; |
| 469 | } |
| 470 | const insertAction: LayoutTreeInsertNodeAtIndexAction = { |
| 471 | type: LayoutTreeActionType.InsertNodeAtIndex, |
| 472 | node: newLayoutNode(undefined, action.nodesize, undefined, { |
| 473 | blockId: action.blockid, |
| 474 | }), |
| 475 | indexArr: action.indexarr, |
| 476 | magnified: action.magnified, |
| 477 | focused: action.focused, |
| 478 | }; |
| 479 | this.treeReducer(insertAction, false); |
| 480 | break; |
| 481 | } |
| 482 | case LayoutTreeActionType.ClearTree: { |
| 483 | this.treeReducer( |
| 484 | { |
| 485 | type: LayoutTreeActionType.ClearTree, |
| 486 | } as LayoutTreeClearTreeAction, |
| 487 | false |
| 488 | ); |
| 489 | break; |
| 490 | } |
| 491 | case LayoutTreeActionType.ReplaceNode: { |
| 492 | const targetNode = this?.getNodeByBlockId(action.targetblockid); |
no test coverage detected