| 149 | |
| 150 | @action |
| 151 | removeDocument(idOrDoc: string | Document) { |
| 152 | let document: Document | undefined |
| 153 | if (typeof idOrDoc === 'string') { |
| 154 | document = this.documents.find(document => document.id === idOrDoc) |
| 155 | } else { |
| 156 | document = idOrDoc |
| 157 | } |
| 158 | |
| 159 | if (!document) { |
| 160 | return logger.warn('document not found', idOrDoc) |
| 161 | } |
| 162 | |
| 163 | const index = this.documents.indexOf(document) |
| 164 | if (index < 0) { |
| 165 | return logger.warn('document not found', idOrDoc) |
| 166 | } |
| 167 | |
| 168 | this.documents.splice(index, 1) |
| 169 | this.documentsMap.delete(document.id) |
| 170 | } |
| 171 | |
| 172 | getDocument(id: string) { |
| 173 | return this.documents.find(doc => doc.id === id) |