Skip to main content

Interface: SiteSyncActions

Defined in: src/stores/sites/useSiteSync.ts:40

Site synchronization actions interface.

Remarksโ€‹

Defines all available site synchronization operations that can be performed. These actions are designed to work within the Zustand store architecture and provide consistent error handling and logging.

Propertiesโ€‹

fullSyncFromBackend()โ€‹

fullSyncFromBackend: () => Promise<void>

Defined in: src/stores/sites/useSiteSync.ts:51

Performs a complete synchronization from the backend.

Returnsโ€‹

Promise<void>

Promise that resolves when synchronization is complete

Remarksโ€‹

Triggers a full sync operation that updates all local site data with the latest information from the backend. This is typically used during application startup or when recovering from errors.


getSyncStatus()โ€‹

getSyncStatus: () => Promise<{ lastSync: undefined | null | number; siteCount: number; success: boolean; synchronized: boolean; }>

Defined in: src/stores/sites/useSiteSync.ts:68

Retrieves current synchronization status from the backend.

Returnsโ€‹

Promise<{ lastSync: undefined | null | number; siteCount: number; success: boolean; synchronized: boolean; }>

Promise resolving to sync status information

Remarksโ€‹

Provides detailed information about the sync state including:

  • Last synchronization timestamp
  • Current site count
  • Overall synchronization status
  • Success/failure indicators

Uses safeExtractIpcData to handle IPC response safely.


subscribeToStatusUpdates()โ€‹

subscribeToStatusUpdates: (callback: (update: StatusUpdate) => void) => { message: string; subscribed: boolean; success: boolean; }

Defined in: src/stores/sites/useSiteSync.ts:94

Establishes subscription to real-time status updates.

Parametersโ€‹

callbackโ€‹

(update: StatusUpdate) => void

Function to call when status updates are received

Returnsโ€‹

Subscription result with success indicators

messageโ€‹

message: string

Human-readable description of the operation

subscribedโ€‹

subscribed: boolean

Whether subscription was successful

successโ€‹

success: boolean

Overall operation success status

Remarksโ€‹

Sets up event listeners for monitor status changes from the backend. Uses the shared StatusUpdateManager to handle:

  • Race condition prevention
  • Fallback mechanisms
  • Efficient incremental updates

subscribeToSyncEvents()โ€‹

subscribeToSyncEvents: () => () => void

Defined in: src/stores/sites/useSiteSync.ts:118

Establishes subscription to backend synchronization events.

Returnsโ€‹

Cleanup function to remove event listeners

(): void

Returnsโ€‹

void

Remarksโ€‹

Listens for various sync events including:

  • Bulk synchronization events
  • Individual site updates
  • Site deletions

Automatically handles different event types and triggers appropriate local state updates.


syncSitesFromBackend()โ€‹

syncSitesFromBackend: () => Promise<void>

Defined in: src/stores/sites/useSiteSync.ts:132

Synchronizes all sites from the backend.

Returnsโ€‹

Promise<void>

Promise that resolves when sync is complete

Remarksโ€‹

Fetches the latest site data from the backend and updates the local store state. Includes comprehensive error handling and logging for debugging purposes.

This is the core synchronization method used by other sync operations.


unsubscribeFromStatusUpdates()โ€‹

unsubscribeFromStatusUpdates: () => { message: string; success: boolean; unsubscribed: boolean; }

Defined in: src/stores/sites/useSiteSync.ts:144

Removes subscription to status updates.

Returnsโ€‹

Unsubscription result with success indicators

messageโ€‹

message: string

Human-readable description of the operation

successโ€‹

success: boolean

Overall operation success status

unsubscribedโ€‹

unsubscribed: boolean

Whether unsubscription was successful

Remarksโ€‹

Cleanly unsubscribes from status update events and releases associated resources. Should be called when components unmount or when status updates are no longer needed.