* Updates the order of open scripts * @param {string} appId - The application ID * @param {Array} openScripts - Array of scripts with their new order * @returns {Promise}
(appId, openScripts)
| 143 | * @returns {Promise} |
| 144 | */ |
| 145 | async updateScriptOrder(appId, openScripts) { |
| 146 | const allScripts = await this.getScripts(appId); |
| 147 | const openScriptIds = openScripts.map(script => script.id); |
| 148 | |
| 149 | const updatedScripts = allScripts.map(script => { |
| 150 | const openScript = openScripts.find(os => os.id === script.id); |
| 151 | if (openScript) { |
| 152 | return { ...script, ...openScript }; |
| 153 | } else if (openScriptIds.includes(script.id)) { |
| 154 | // Script was previously open but not in the new list, close it |
| 155 | return { ...script, order: undefined }; |
| 156 | } |
| 157 | return script; |
| 158 | }); |
| 159 | |
| 160 | await this.saveScripts(appId, updatedScripts); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Completely deletes a script from storage |
no test coverage detected