* Load TOC from the CSV-as-JSON endpoint. Resolves when the Foldr is ready.
(id: string)
| 88 | * Load TOC from the CSV-as-JSON endpoint. Resolves when the Foldr is ready. |
| 89 | */ |
| 90 | async fetch(id: string): Promise<this> { |
| 91 | this.id = id; |
| 92 | const body = await this.loadTocJson(); |
| 93 | if (Array.isArray(body) && body.length > 0) { |
| 94 | this.rows = parseTocBody(body); |
| 95 | } else { |
| 96 | this.wasNonExistent = true; |
| 97 | } |
| 98 | |
| 99 | if (this.rows.length === 0) { |
| 100 | this.wasEmpty = true; |
| 101 | const seed: FoldrRow = { link: `/${this.id}.1`, title: 'Sheet1', row: 2 }; |
| 102 | this.rows = []; |
| 103 | await this.push(seed); |
| 104 | } |
| 105 | return this; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Re-fetch the TOC without seeding or touching init flags. Returns `true` |
no test coverage detected