PlugSnatcher/frontend_backend_sync_checklist.md

2.4 KiB

Backend Changes (src-tauri/)

  • Create load_plugin_data Command:
    • Implement a command load_plugin_data(app_handle: AppHandle, server_path: String) -> Result<Vec<Plugin>, String>.
    • Use get_plugin_data_path from scanner.rs to find the correct plugins.json.
    • Read and deserialize plugins.json.
    • Return Ok(plugins) or an appropriate Err(String).
    • Register the command in lib.rs.
  • Create save_plugin_data Command:
    • Implement a command save_plugin_data(app_handle: AppHandle, plugins: Vec<Plugin>, server_path: String) -> Result<(), String>.
    • Use get_plugin_data_path from scanner.rs.
    • Serialize the plugins vector to JSON.
    • Write the JSON to plugins.json, creating the directory if needed.
    • Return Ok(()) or an appropriate Err(String).
    • Register the command in lib.rs.
  • Align Bulk Update Events/Logic:
    • In update_checker.rs (check_for_plugin_updates), rename the emitted event from "update_check_started" to "bulk_update_start".
    • In update_checker.rs (check_for_plugin_updates), remove the app_handle.emit("update_check_completed", ()) call. The result should be handled via the command's return value.

Frontend Changes (src/App.tsx)

  • Align Plugin Interface Nullability:
    • Ensure depend, soft_depend, and load_before fields consistently use string[] | null.
  • Rename Command Invokes:
    • Change invoke("check_single_plugin_update", ...) to invoke("check_single_plugin_update_command", ...).
    • Change invoke("set_plugin_repository_source", ...) to invoke("set_plugin_repository", ...).
  • Refactor checkForUpdates Result Handling:
    • Modify the checkForUpdates async function to await the invoke("check_plugin_updates", ...) call.
    • Use a try...catch block or .then().catch() to handle the Result<Vec<Plugin>, String>.
    • On success (Ok(updatedPlugins)), call setPlugins(updatedPlugins) and clear errors/loading states.
    • On error (Err(error)), call setUpdateError(error) and clear loading states.
  • Adjust/Remove Event Listeners:
    • In useEffect, rename the listener for "update_check_started" to "bulk_update_start".
    • In useEffect, remove the listeners for "bulk_update_complete" and "bulk_update_error".