* Create an empty AppRoot with a placeholder "skeleton" element. * @param mainScriptHash - The hash of the main script that creates this AppRoot. * @param isInitialRender - Whether this is the initial render. * @param sidebarElements - The elements to add to the sidebar (this was a relic
(
mainScriptHash = "",
isInitialRender = true,
sidebarElements?: BlockNode,
logo?: Logo | null
)
| 98 | * @returns A new AppRoot with the given parameters. |
| 99 | */ |
| 100 | public static empty( |
| 101 | mainScriptHash = "", |
| 102 | isInitialRender = true, |
| 103 | sidebarElements?: BlockNode, |
| 104 | logo?: Logo | null |
| 105 | ): AppRoot { |
| 106 | const mainNodes: AppNode[] = [] |
| 107 | |
| 108 | let waitElement: Element | undefined |
| 109 | |
| 110 | switch (getLoadingScreenType()) { |
| 111 | case LoadingScreenType.NONE: |
| 112 | break |
| 113 | |
| 114 | case LoadingScreenType.V1: |
| 115 | // Only show the v1 loading state when it's the initial render. |
| 116 | // This is how v1 used to work, and we don't want any backward |
| 117 | // incompatibility. |
| 118 | if (isInitialRender) { |
| 119 | waitElement = makeElementWithInfoText("Please wait...") |
| 120 | } |
| 121 | break |
| 122 | |
| 123 | default: |
| 124 | waitElement = makeAppSkeletonElement() |
| 125 | break |
| 126 | } |
| 127 | |
| 128 | if (waitElement) { |
| 129 | mainNodes.push( |
| 130 | new ElementNode( |
| 131 | waitElement, |
| 132 | ForwardMsgMetadata.create({}), |
| 133 | NO_SCRIPT_RUN_ID, |
| 134 | mainScriptHash |
| 135 | ) |
| 136 | ) |
| 137 | } |
| 138 | |
| 139 | const main = new BlockNode( |
| 140 | mainScriptHash, |
| 141 | mainNodes, |
| 142 | new BlockProto({ allowEmpty: true }), |
| 143 | NO_SCRIPT_RUN_ID |
| 144 | ) |
| 145 | |
| 146 | const sidebar = |
| 147 | sidebarElements || |
| 148 | new BlockNode( |
| 149 | mainScriptHash, |
| 150 | [], |
| 151 | new BlockProto({ allowEmpty: true }), |
| 152 | NO_SCRIPT_RUN_ID |
| 153 | ) |
| 154 | |
| 155 | const event = new BlockNode( |
| 156 | mainScriptHash, |
| 157 | [], |