( existing: PersistedConsoleData | null, incoming: PersistedConsoleData )
| 140 | } |
| 141 | |
| 142 | function mergePersistedConsoleData( |
| 143 | existing: PersistedConsoleData | null, |
| 144 | incoming: PersistedConsoleData |
| 145 | ): PersistedConsoleData { |
| 146 | if (!existing) return incoming |
| 147 | const workflowIds = new Set([ |
| 148 | ...Object.keys(existing.workflowEntries), |
| 149 | ...Object.keys(incoming.workflowEntries), |
| 150 | ]) |
| 151 | const workflowEntries: Record<string, ConsoleEntry[]> = {} |
| 152 | |
| 153 | for (const workflowId of workflowIds) { |
| 154 | const entries = mergeEntries( |
| 155 | existing.workflowEntries[workflowId], |
| 156 | incoming.workflowEntries[workflowId] |
| 157 | ) |
| 158 | if (entries.length > 0) workflowEntries[workflowId] = entries |
| 159 | } |
| 160 | |
| 161 | return { |
| 162 | workflowEntries, |
| 163 | isOpen: incoming.isOpen, |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | function writeToIndexedDB( |
| 168 | data: PersistedConsoleData, |
no test coverage detected