Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
Merge branch 'feat/appflowy_tauri_3' into feat/appflowy_tauri_3
Nathan.fooo0b2dc415af10
diff --cc frontend/appflowy_tauri/src/appflowy_app/components/auth/ProtectedRoutes.tsxindex 4904194cb9,5b8bde9576..eb8cdac5a2--- a/frontend/appflowy_tauri/src/appflowy_app/components/auth/ProtectedRoutes.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/auth/ProtectedRoutes.tsx@@@ -1,16 -1,55 +1,56 @@@- import { Navigate, Outlet, useLocation } from 'react-router-dom';+ import { Outlet } from 'react-router-dom';import { useAuth } from './auth.hooks';import { Screen } from '../layout/Screen';+ import { useEffect, useState } from 'react';+ import { GetStarted } from './GetStarted/GetStarted';+ import { AppflowyLogo } from '../_shared/svg/AppflowyLogo';++export const ProtectedRoutes = () => {- const location = useLocation();- const { currentUser } = useAuth();-- return currentUser.isAuthenticated ? (- <Screen>- <Outlet />- </Screen>- ) : (- <Navigate to='/auth/getStarted' replace state={{ from: location }} />+ const { currentUser, checkUser } = useAuth();+ const [isLoading, setIsLoading] = useState(true);++ useEffect(() => {+ void checkUser().then(async (result) => {+ await new Promise(() =>+ setTimeout(() => {+ setIsLoading(false);+ }, 1200)+ );++ if (result.err) {+ throw new Error(result.val.msg);+ }++ });+ }, []);++ if (isLoading) {+ // It's better to make a fading effect to disappear the loading page+ return <StartLoading />;+ } else {+ return <SplashScreen isAuthenticated={currentUser.isAuthenticated} />;+ }+ };++ const StartLoading = () => {+ return (+ <div className='flex h-screen w-full flex-col items-center justify-center'>+ <div className='h-40 w-40 justify-center'>+ <AppflowyLogo />+ </div>+ </div>);};++ const SplashScreen = ({ isAuthenticated }: { isAuthenticated: boolean }) => {+ if (isAuthenticated) {+ return (+ <Screen>+ <Outlet />+ </Screen>+ );+ } else {+ return <GetStarted></GetStarted>;+ }+ };diff --cc frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_controller.tsindex 853bc2f006,89d9446b05..1e5d45a9b7--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_controller.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_controller.ts@@@ -110,12 -113,12 +113,12 @@@ export class CellController<T, D>};}- class CellDataNotifier<T> extends ChangeNotifier<T | null> {+ class CellDataNotifier<T> extends ChangeNotifier<T> {_cellData: Option<T>;- constructor(cellData: T) {+ constructor(cellData: Option<T>) {super();- this._cellData = cellData;+ this._cellData = Some(cellData);}set cellData(data: Option<T>) {diff --cc frontend/rust-lib/flowy-database/src/services/database_view/editor_manager.rsindex 3d68613a4e,c8cf5f5453..303d54a681--- a/frontend/rust-lib/flowy-database/src/services/database_view/editor_manager.rs+++ b/frontend/rust-lib/flowy-database/src/services/database_view/editor_manager.rs@@@ -60,12 -61,8 +61,9 @@@ impl DatabaseViews}pub async fn close(&self, view_id: &str) {- if let Ok(mut view_editors) = self.view_editors.try_write() {- if let Some(view_editor) = view_editors.remove(view_id) {- view_editor.close().await;- }- } else {- tracing::error!("Try to get the lock of view_editors failed");+ if let Some(view_editor) = self.view_editors.write().await.remove(view_id) {+ view_editor.close().await;++}}