MCPcopy
hub / github.com/callumalpass/tasknotes / reorderSavedViews

Method reorderSavedViews

src/services/ViewStateManager.ts:348–371  ·  view source on GitHub ↗

* Reorder saved views by moving a view from one position to another

(fromIndex: number, toIndex: number)

Source from the content-addressed store, hash-verified

346 * Reorder saved views by moving a view from one position to another
347 */
348 reorderSavedViews(fromIndex: number, toIndex: number): void {
349 if (
350 fromIndex < 0 ||
351 fromIndex >= this.savedViews.length ||
352 toIndex < 0 ||
353 toIndex > this.savedViews.length ||
354 fromIndex === toIndex
355 ) {
356 return;
357 }
358
359 // Clamp toIndex to valid range
360 toIndex = Math.min(toIndex, this.savedViews.length - 1);
361
362 // Remove the view from its current position
363 const [movedView] = this.savedViews.splice(fromIndex, 1);
364
365 // Insert it at the new position
366 this.savedViews.splice(toIndex, 0, movedView);
367
368 // Save the reordered views
369 void this.saveSavedViewsToPluginData();
370 this.emit("saved-views-changed", this.getSavedViews());
371 }
372
373 /**
374 * Generate a unique ID for saved views

Callers

nothing calls this directly

Calls 3

getSavedViewsMethod · 0.95
emitMethod · 0.80

Tested by

no test coverage detected