(scope: WorkspaceScope)
| 299 | } |
| 300 | |
| 301 | function getPageFileQueue(scope: WorkspaceScope): PersistenceQueue<string, PageFileMutation> { |
| 302 | return getOrCreateQueue(workspaceQueueId(scope, 'page-file'), () => |
| 303 | createPersistenceQueue<string, PageFileMutation>( |
| 304 | async (pageId, mutation) => { |
| 305 | if (mutation.deletePage) { |
| 306 | await persistence.workspace(scope).pages.deleteWithMessages(pageId) |
| 307 | return |
| 308 | } |
| 309 | |
| 310 | if (mutation.page) { |
| 311 | await flushQueue(getFoldersQueue(scope)) |
| 312 | await persistence.workspace(scope).pages.put(mutation.page) |
| 313 | } |
| 314 | |
| 315 | if (mutation.messages !== undefined) { |
| 316 | if (mutation.messages === null) { |
| 317 | await persistence.workspace(scope).messages.delete(pageId) |
| 318 | } else { |
| 319 | await persistence.workspace(scope).messages.put(pageId, mutation.messages) |
| 320 | } |
| 321 | } |
| 322 | }, |
| 323 | { |
| 324 | ...DEFAULT_QUEUE_OPTIONS, |
| 325 | mergePending: mergePageFileMutation |
| 326 | } |
| 327 | ) |
| 328 | ) |
| 329 | } |
| 330 | |
| 331 | export function queueFoldersSnapshot(scope: WorkspaceScope, folders: PageFolder[]): void { |
| 332 | getFoldersQueue(scope).enqueue('folders', folders) |
no test coverage detected