(rawQueue: unknown)
| 178 | } |
| 179 | |
| 180 | function parseQueueSnapshot(rawQueue: unknown): StreamQueueItem[] | undefined { |
| 181 | if (!Array.isArray(rawQueue)) { |
| 182 | return undefined |
| 183 | } |
| 184 | |
| 185 | const snapshot: StreamQueueItem[] = [] |
| 186 | |
| 187 | for (const entry of rawQueue) { |
| 188 | if (!isRecord(entry)) { |
| 189 | continue |
| 190 | } |
| 191 | |
| 192 | const idRaw = entry.id |
| 193 | if (typeof idRaw !== "string" || idRaw.trim().length === 0) { |
| 194 | continue |
| 195 | } |
| 196 | |
| 197 | const imagesRaw = entry.images |
| 198 | const timestampRaw = entry.timestamp |
| 199 | const imageCount = Array.isArray(imagesRaw) ? imagesRaw.length : 0 |
| 200 | |
| 201 | snapshot.push({ |
| 202 | id: idRaw, |
| 203 | text: normalizeQueueText(typeof entry.text === "string" ? entry.text : undefined), |
| 204 | imageCount, |
| 205 | timestamp: typeof timestampRaw === "number" ? timestampRaw : undefined, |
| 206 | }) |
| 207 | } |
| 208 | |
| 209 | return snapshot |
| 210 | } |
| 211 | |
| 212 | function areStringArraysEqual(a: string[], b: string[]): boolean { |
| 213 | if (a.length !== b.length) { |
no test coverage detected