WIP: refactor: profiles in the store #12

Draft
warren wants to merge 26 commits from profile into main
Collaborator

This PR introduces a "Profile" struct and refactors the code to store these in the store alongside their avatar. Profiles have a UUID (See #11) , which are now referred to as the sender in MessageData

Depends on: #9

This PR introduces a "Profile" struct and refactors the code to store these in the store alongside their avatar. Profiles have a UUID (See https://kitsunes.dev/nemalixi/chat-app/issues/11) , which are now referred to as the sender in MessageData Depends on: https://kitsunes.dev/nemalixi/chat-app/pulls/9
ChatView will need to accept data externally. Putting mock data straight into the slint file makes not much sense - we'll feed that from rust-land if need be.
Introduced `ChatData` struct to encapsulate both messages and chat title, and updated ChatData to use this struct, making the data better-encapsulated for feeding in through a larger data model.
Replaced hardcoded `ChatView` instances with dynamic rendering using `views` and `chat-data` properties, enabling better integration with Rust-land.
Added placeholder_data.rs which contains two sets of example chat messages with which to fill out the UI.
the `chat-data` and `views` properties were populated with placeholder data from Rust, demonstrating how information flows from Rust to Slint components.
Slint's types want an Image value, which underneath the hood uses a reference-counted value, but it was awkward to keep track of those references.

The cache makes it easier by just letting you get images from there by cache.
Slint types are annoyingly opinionated in terms of all the mechanics that are in there for observing and tracking data, none of which should end up in the networking code.

This commit introduces far more Vanilla Rust plain-old-data types that mirror the generated Slint types.
Replaced `SharedString` and `Image` with vanilla Rust `String` and `PathBuf`. Updated `ChatData` and `MessageData` to depend on plain data types.
Added the `Store` trait to handle long-term storage of user data, including methods for fetching all chat UUIDs and retrieving chat data by UUID.
Introduced a placeholder implementation of the `Store` trait with predefined chat data for testing and demonstration. Updated `store` module to include `placeholder_store`.
Replaced static chat data and views initialization with dynamic data retrieved using the new `PlaceholderStore` implementation.
Replaced raw `Uuid` usage with `ChatUuid` newtype across `Store` implementations to prevent mixing up identifiers.
Refactored `create_simple_sample_messages` and `create_complex_sample_messages` to return `ChatData` instead of `Vec<MessageData>`.
ChatData now has a uuid field rather than this being implicit in the store hashmap
the Profile struct is untriduced to represent a bit of metadata about a profile.
Replaced inline UUID definitions with reusable constants.
Extended the `Store` trait and `PlaceholderStore` to handle `Profile` data. Introduced methods to retrieve profiles by UUID and iterate over all profiles. Populated the `PlaceholderStore` with sample profiles.
Changed MessageData to refer to the sender by its uuid, dropping the avatar.

Processed the consequence of now having to look up the profile when handing stuff off to Slint.
warren changed title from refactor: profiles in the store to WIP: refactor: profiles in the store 2025-11-27 13:46:30 +00:00
Until now, the UI showed a fixed set of placeholder profiles. This commit forwards the profiles from teh store into the ui.
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin profile:profile
git switch profile
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
nemalixi/chat-app!12
No description provided.