Skip to content

fix: user name stay no change when reopen the setting menu after renaming#7828

Merged
appflowy merged 3 commits intomainfrom
fix_user_rename
Apr 25, 2025
Merged

fix: user name stay no change when reopen the setting menu after renaming#7828
appflowy merged 3 commits intomainfrom
fix_user_rename

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Apr 24, 2025

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Refactor user profile management to improve state handling and synchronization across the application

Bug Fixes:

  • Fix user name not updating when reopening the settings menu after renaming

Enhancements:

  • Centralize user profile state management in UserWorkspaceBloc
  • Add support for dynamically updating user profile across different components

Chores:

  • Remove redundant user profile references
  • Update multiple components to use centralized user profile state

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 24, 2025

Reviewer's Guide by Sourcery

This pull request refactors how the user profile is managed and propagated throughout the application, ensuring that updates to the user profile (such as renaming) are immediately reflected in the UI, even after reopening the settings menu. The changes centralize user profile state management within the UserWorkspaceBloc, update all relevant UI components to consume the user profile from the bloc's state, and improve the reactivity of the settings dialog and related widgets. Additionally, the PR introduces workspace type handling in several places, and makes related adjustments in both Flutter and Rust code to support this. Redundant passing of user profile objects as parameters is removed, and event handling is improved to prevent UI staleness.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Centralize user profile state management in UserWorkspaceBloc and propagate updates reactively.
  • UserWorkspaceBloc now stores userProfile in its state and emits updates when the profile changes.
  • User profile updates are handled via a new updateUserProfile event, triggered by UserListener callbacks.
  • All UI components and logic that previously accessed userProfile directly or via constructor parameters now read it from UserWorkspaceBloc's state.
  • SettingsDialog and related widgets are updated to use the latest userProfile from the bloc state, ensuring UI reflects changes immediately.
  • Redundant passing of userProfile as a parameter to widgets and functions is removed.
frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_setting.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_user.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/footer/sidebar_toast.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/hotkeys.dart
frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_bottom_sheet.dart
frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_menu.dart
frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_message_selector_banner.dart
frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_message_action_bar.dart
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/custom_image_block_component/image_menu.dart
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/multi_image_block_component/layouts/image_browser_layout.dart
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/resizeable_image.dart
Improve settings dialog and related bloc to react to user profile changes and remove stale state.
  • SettingsDialogBloc no longer stores its own userProfile; it now always uses the latest from UserWorkspaceBloc state.
  • UserListener callbacks in SettingsDialogBloc check for bloc closure before dispatching events to avoid errors.
  • SettingsDialog and related widgets are refactored to not require userProfile as a constructor argument.
frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_setting.dart
Introduce and propagate workspace type information throughout the application.
  • AppFlowyCloudSettingBloc and ViewInfoBloc now fetch and store workspaceType in their state.
  • WorkspaceTypePB is fetched from the user profile and used to control UI logic (e.g., feature visibility).
  • UI components conditionally render features based on workspaceType (e.g., enabling sync only for certain workspace types).
frontend/appflowy_flutter/lib/workspace/application/settings/appflowy_cloud_setting_bloc.dart
frontend/appflowy_flutter/lib/workspace/application/view_info/view_info_bloc.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart
frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart
Update Rust backend to support workspace type in workspace settings.
  • WorkspaceSettingsPB struct now includes workspace_type field.
  • Conversion logic for WorkspaceSettingsPB is updated to set workspace_type appropriately.
  • UserManager's get_workspace_settings method now fetches and sets workspace_type from the database.
frontend/rust-lib/flowy-user/src/entities/workspace.rs
frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @appflowy - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@appflowy appflowy merged commit 7f13790 into main Apr 25, 2025
7 of 8 checks passed
@appflowy appflowy deleted the fix_user_rename branch April 25, 2025 06:02
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