(port)
| 224 | } |
| 225 | |
| 226 | async function undoImport(port) { |
| 227 | let drop; |
| 228 | let old; |
| 229 | port.onDisconnect.addListener(() => { |
| 230 | ignoreChromeErrors(); |
| 231 | drop = true; |
| 232 | }); |
| 233 | port.onMessage.addListener(async () => { |
| 234 | valuesToFlush = {}; |
| 235 | const cur = await cachedStorageApi.get(); |
| 236 | const toRemove = Object.keys(cur).filter(k => !(k in old)); |
| 237 | const delay = Math.max(50, Math.min(500, performance.getEntries()[0]?.duration || 200)); |
| 238 | undoing = true; |
| 239 | if (toRemove.length) await cachedStorageApi.remove(toRemove); |
| 240 | await cachedStorageApi.set(old); |
| 241 | port.postMessage(true); |
| 242 | await sendCmd('Reload', delay); |
| 243 | location.reload(); |
| 244 | }); |
| 245 | old = await api.get(); |
| 246 | if (!drop) port.postMessage(true); |
| 247 | } |
no test coverage detected