* Update an existing saved view
(viewId: string, updates: Partial<SavedView>)
| 261 | * Update an existing saved view |
| 262 | */ |
| 263 | updateView(viewId: string, updates: Partial<SavedView>): void { |
| 264 | const viewIndex = this.savedViews.findIndex((v) => v.id === viewId); |
| 265 | if (viewIndex === -1) { |
| 266 | throw new Error(`Saved view with ID ${viewId} not found`); |
| 267 | } |
| 268 | |
| 269 | // Deep clone the query if it's being updated |
| 270 | const clonedUpdates = { ...updates }; |
| 271 | if (clonedUpdates.query) { |
| 272 | clonedUpdates.query = FilterUtils.deepCloneFilterQuery(clonedUpdates.query); |
| 273 | } |
| 274 | if (clonedUpdates.viewOptions) { |
| 275 | clonedUpdates.viewOptions = { ...clonedUpdates.viewOptions }; |
| 276 | } |
| 277 | |
| 278 | this.savedViews[viewIndex] = { |
| 279 | ...this.savedViews[viewIndex], |
| 280 | ...clonedUpdates, |
| 281 | }; |
| 282 | |
| 283 | void this.saveSavedViewsToPluginData(); |
| 284 | this.emit("saved-views-changed", this.getSavedViews()); |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Delete a saved view |
nothing calls this directly
no test coverage detected