Skip to content

Commit

Permalink
chore: fix ai page user profile refresh (#7317)
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Feb 4, 2025
1 parent e9201cc commit 122fb89
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ class SettingsAIBloc extends Bloc<SettingsAIEvent, SettingsAIState> {
if (!models.contains(state.selectedAIModel)) {
// Use first model as default model if current selected model
// is not available
final selectedModel = models[0];
_updateUserWorkspaceSetting(model: selectedModel);
emit(
state.copyWith(
availableModels: models,
selectedAIModel: models[0],
selectedAIModel: selectedModel,
),
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class SettingsDialog extends StatelessWidget {
case SettingsPage.ai:
if (user.authenticator == AuthenticatorPB.AppFlowyCloud) {
return SettingsAIView(
key: ValueKey(user.hashCode),
userProfile: user,
currentWorkspaceMemberRole: currentWorkspaceMemberRole,
workspaceId: workspaceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use client_api::entity::{
use client_api::entity::{QueryCollab, QueryCollabParams};
use client_api::{Client, ClientConfiguration};
use collab_entity::{CollabObject, CollabType};
use tracing::instrument;
use tracing::{instrument, trace};

use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use flowy_user_pub::cloud::{UserCloudService, UserCollabParams, UserUpdate, UserUpdateReceiver};
Expand Down Expand Up @@ -586,6 +586,7 @@ where
workspace_id: &str,
workspace_settings: AFWorkspaceSettingsChange,
) -> Result<AFWorkspaceSettings, FlowyError> {
trace!("Sync workspace settings: {:?}", workspace_settings);
let workspace_id = workspace_id.to_string();
let try_get_client = self.server.try_get_client();
let client = try_get_client?;
Expand Down
6 changes: 3 additions & 3 deletions frontend/rust-lib/flowy-user/src/entities/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl From<AFWorkspaceSettings> for UseAISettingPB {
}
}

#[derive(ProtoBuf, Default, Clone, Validate)]
#[derive(ProtoBuf, Default, Clone, Validate, Debug)]
pub struct UpdateUserWorkspaceSettingPB {
#[pb(index = 1)]
#[validate(custom(function = "required_not_empty_str"))]
Expand All @@ -410,10 +410,10 @@ impl From<UpdateUserWorkspaceSettingPB> for AFWorkspaceSettingsChange {
fn from(value: UpdateUserWorkspaceSettingPB) -> Self {
let mut change = AFWorkspaceSettingsChange::new();
if let Some(disable_search_indexing) = value.disable_search_indexing {
change = change.disable_search_indexing(disable_search_indexing);
change.disable_search_indexing = Some(disable_search_indexing);
}
if let Some(ai_model) = value.ai_model {
change = change.ai_model(ai_model);
change.ai_model = Some(ai_model);
}
change
}
Expand Down

0 comments on commit 122fb89

Please sign in to comment.