Mathias Mogensen 54c9d12171
feat: support switch model (#5575)
* feat: ai settings page

* chore: intergate client api

* chore: replace open ai calls

* chore: disable gen image from ai

* chore: clippy

* chore: remove learn about ai

* chore: fix wanrings

* chore: fix restart button title

* chore: remove await

* chore: remove loading indicator

---------

Co-authored-by: nathan <nathan@appflowy.io>
Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
2024-06-25 07:59:38 +08:00

41 lines
1.0 KiB
Rust

use flowy_derive::ProtoBuf_Enum;
use flowy_notification::NotificationBuilder;
use crate::entities::AuthStateChangedPB;
const USER_OBSERVABLE_SOURCE: &str = "User";
#[derive(ProtoBuf_Enum, Debug, Default)]
pub(crate) enum UserNotification {
#[default]
Unknown = 0,
UserAuthStateChanged = 1,
DidUpdateUserProfile = 2,
DidUpdateUserWorkspaces = 3,
DidUpdateCloudConfig = 4,
DidUpdateUserWorkspace = 5,
DidUpdateAISetting = 6,
}
impl std::convert::From<UserNotification> for i32 {
fn from(notification: UserNotification) -> Self {
notification as i32
}
}
#[tracing::instrument(level = "trace")]
pub(crate) fn send_notification(id: &str, ty: UserNotification) -> NotificationBuilder {
NotificationBuilder::new(id, ty, USER_OBSERVABLE_SOURCE)
}
#[tracing::instrument(level = "trace")]
pub(crate) fn send_auth_state_notification(payload: AuthStateChangedPB) {
NotificationBuilder::new(
"auth_state_change_notification",
UserNotification::UserAuthStateChanged,
USER_OBSERVABLE_SOURCE,
)
.payload(payload)
.send()
}