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

Method notifyDataChanged

src/main.ts:625–656  ·  view source on GitHub ↗

* Notify views that data has changed and views should refresh * @param filePath Optional path of the file that changed (for targeted cache invalidation) * @param force Whether to force a full cache rebuild * @param triggerRefresh Whether to trigger a full UI refresh (default true)

(filePath?: string, force = false, triggerRefresh = true)

Source from the content-addressed store, hash-verified

623 * @param triggerRefresh Whether to trigger a full UI refresh (default true)
624 */
625 notifyDataChanged(filePath?: string, force = false, triggerRefresh = true): void {
626 // Clear cache entries for native cache manager
627 if (filePath) {
628 this.cacheManager.clearCacheEntry(filePath);
629
630 // Clear task link detection cache for this file
631 if (this.taskLinkDetectionService) {
632 this.taskLinkDetectionService.clearCacheForFile(filePath);
633 }
634 } else if (force) {
635 // Full cache clear if forcing
636 void this.cacheManager.clearAllCaches();
637
638 // Clear task link detection cache completely
639 if (this.taskLinkDetectionService) {
640 this.taskLinkDetectionService.clearCache();
641 }
642 }
643
644 // Only emit refresh event if triggerRefresh is true
645 if (triggerRefresh) {
646 // Use requestAnimationFrame for better UI timing instead of setTimeout
647 window.requestAnimationFrame(() => {
648 this.emitter.trigger(EVENT_DATA_CHANGED);
649 this.emitter.trigger(TASKNOTES_RUNTIME_LIFECYCLE_RAW_EVENTS["cache.changed"], {
650 filePath,
651 force,
652 timestamp: new Date().toISOString(),
653 });
654 });
655 }
656 }
657
658 /**
659 * Set up date change detection to refresh task states when the date rolls over

Callers 6

navigateToDailyNoteMethod · 0.95
refreshCacheMethod · 0.95
initializeServicesLazilyFunction · 0.80

Calls 5

clearCacheForFileMethod · 0.80
clearAllCachesMethod · 0.80
clearCacheEntryMethod · 0.65
triggerMethod · 0.65
clearCacheMethod · 0.45

Tested by

no test coverage detected