Skip to content

refactor: improve board index management and loading logic#6

Merged
clFaster merged 1 commit intomainfrom
chore/improve-code-quality
Mar 15, 2026
Merged

refactor: improve board index management and loading logic#6
clFaster merged 1 commit intomainfrom
chore/improve-code-quality

Conversation

@clFaster
Copy link
Owner

@clFaster clFaster commented Mar 15, 2026

This pull request includes significant refactoring and improvements to both the backend (Rust) and frontend (React/TypeScript) codebases, focusing on better modularization, clearer separation of concerns, and improved loading/error handling in the UI. The backend changes restructure how board and folder data are persisted and loaded from the database, while the frontend introduces new components for loading and error states and refactors the Excalidraw frame's persistence logic.

Backend (Rust) - Boards Index & Persistence:

  • Refactored database logic for board/folder index:
    • Broke down the monolithic set_boards_index function into smaller helper functions: clear_index_tables, persist_index_item, persist_folder_item, and resolve_active_board_id, improving readability and maintainability.
    • Enhanced the loading process for boards index by introducing load_boards_map, load_folder_names_map, and load_index_items, and refactored the row-to-item conversion logic for more robust and modular data handling. [1] [2] [3]
    • Improved the logic for resolving the first board ID and handling folders within the index, consolidating duplicate code and making the retrieval process more reliable.

Frontend (React/TypeScript) - UI Structure & Persistence:

  • UI loading and error handling improvements:

    • Introduced new components: FullScreenLoading, ExcalidrawLoadingOverlay, and AppErrorToast for consistent and reusable loading and error UI states. [1] [2]
    • Refactored the main App component to use these new UI components, simplifying conditional rendering and improving user experience.
  • Excalidraw frame persistence refactor:

    • Split the persistence logic into two custom hooks: useExcalidrawDataPersistence (for board data) and useExcalidrawThumbnailPersistence (for thumbnail images), clarifying responsibilities and making the codebase easier to extend and maintain. [1] [2] [3] [4]

These changes collectively make the codebase more modular, maintainable, and robust, while also providing a smoother user experience during loading and error conditions.

Backend (Rust) - Boards Index & Persistence

  • Refactored set_boards_index into smaller helper functions for clearing tables, persisting items, and resolving the active board, improving maintainability and clarity.
  • Modularized the database loading logic for boards and folders, introducing helper functions for mapping and row conversion, resulting in more robust and reusable data access patterns. [1] [2] [3]
  • Improved active board ID resolution and folder/board retrieval logic for greater reliability.

Frontend (React/TypeScript) - UI & Persistence

  • Added reusable loading and error UI components (FullScreenLoading, ExcalidrawLoadingOverlay, AppErrorToast) and refactored the App component to use them for a cleaner and more consistent user experience. [1] [2] [3]
  • Separated Excalidraw data and thumbnail persistence logic into distinct hooks, clarifying responsibilities and improving code maintainability. [1] [2] [3] [4]

@clFaster clFaster marked this pull request as ready for review March 15, 2026 13:11
@clFaster clFaster merged commit 7fe3df0 into main Mar 15, 2026
3 checks passed
@clFaster clFaster deleted the chore/improve-code-quality branch March 15, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant