⭐Favorites
Mihir Singh
Introduction
Managing and organizing vast amounts of data can be a daunting task. Whether it's navigating through numerous files and folders or trying to locate specific information within a page, the process can often become overwhelming.
As users of productivity tools like AppFlowy, we often find ourselves grappling with the challenge of efficiently accessing and prioritizing the content that matters most to us.
A favorite mechanism can alleviate this problem of navigating through a vast database by offering users a simple and effective go-to mechanism.
Goal
Goal of this project is to provide users with efficient mechanism for managing and accessing their most important and frequently used content by allowing users to mark views as favorites, the feature aims at advanced navigation, organization and productivity within the app.
Scope
Favorite a Page: Users can easily mark a page as a favorite by navigating to the desired page and clicking a dedicated button at the top-right corner. This action signifies the user's preference for quick access to the selected page.
Favorites Section: A dedicated Favorites section will be introduced in the left sidebar of the AppFlowy interface. Once the user has favorited their first page, this section will automatically appear. It provides users with a centralized location to find their pinned pages and related subdirectories, ensuring easy access to their most important and frequently accessed content.
Remove from Favorites: Users have the flexibility to unpin or remove a page from their Favorites section, allowing them to update their prioritization and keep the Favorites section relevant to their current needs and preferences.
Implementation Design
To implement the favorites feature in AppFlowy, a comprehensive approach involving changes in both AppFlowy's rust and flutter components is proposed. AppFlowy's persitence logic which was previously part of rust-lib in AppFlowy is now separated to a different repository AppFlowy-Collab, current plan is to introduce following changes:
Changes to Existing Persistence Structs (Rust):
Each item displayed in the left sidebar will be represented as a
View
struct. The concept of an 'App' is deprecated.The
View
struct is defined in thefolder-collab
crate and exposed using theViewPB
struct.A new variable named
is_favorites
will be introduced in theView
andViewPB
structs. This variable will indicate whether a specific view is a favorite without the need to iterate through all favorited views.
Introduction of New Structs (Rust):
Two new structs,
FavoritesInfo
andFavoritesArray
, will be introduced in thecollab
module.FavoritesInfo
will only hold theview_id
of the favorited view. This will allow separate persistence of the favorite views.FavoritesArray
will utilizeArrayRefWrapper
andViewsMap
as underlying constructs to persist all the favorite views.
Calculation of Favorite Views and Data Transfer (Rust):
The handlers in the Rust library (
rust-lib
) will handle requests from the frontend to calculate the views marked as favorites based on user interactions.On every new launch of AppFlowy, a
FolderEvent
namedReadFavorites
will be sent torust-lib
. This event will be handled by aread_favorites_handler
function, which will retrieve all the favorite views from persistence, map them toRepeatedViewPB
(a list ofViewPB
), and return them to the frontend for display under the favorites section.When a favorite is toggled for a view, a
FolderEvent
namedToggleFavorite
will be triggered, carrying theviewId
of the designated view. This event will be handled by thetoggle_favorites
function inrust-lib
.If the view is not currently marked as a favorite, it will be added and persisted to the list of favorites.
If the view is already marked as a favorite, it will be removed from the list of favorites, effectively unfavoriting it.
Furthermore, a
ViewPB
will be created and returned to the frontend. ThisViewPB
object will represent the updated view and can be appended to the visible list of views in the favorites section. This ensures that the UI accurately reflects the updated favorite status of the view.
Notification Handling (Rust):
A notification system will be implemented to handle updates to the favorite status of views.
When the favorite status of a view is updated, a notification named
DidUpdateView
underFolderNotification
will be triggered to update the favorite status of the individual view.A
FolderNotification
namedFavoritesUpdated
will be sent every time favorite status of a view is updated. This notification will carry a list of the updated favorite views, which will be displayed under the favorites section in Flutter.
Integration with UI (Flutter):
The Flutter component will incorporate a dedicated bloc and service to handle the favorites functionality.
This module will be responsible for sending events to
rust-lib
and processing the notifications received with those events to appropriately update the views in the UI.
Handling Edge Cases (Flutter):
Additional notifications will be handled when a view's data is updated in the menu. For example, if a view is renamed, deleted, or its icon is updated, these changes will be propagated to the associated view under the favorites section.
Expected Schedule
By July 6th (Estimated)
By 12th July (Estimated)
By 20th July (Estimated)
Last updated