[rust]: Reset INIT_WORKSPACE flag for flutter's hot reload

This commit is contained in:
appflowy 2021-11-11 11:40:59 +08:00
parent 89bb50eb44
commit fa683e48c0
3 changed files with 8 additions and 1 deletions

View File

@ -70,4 +70,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
COCOAPODS: 1.11.2
COCOAPODS: 1.10.1

View File

@ -206,6 +206,7 @@ async fn fetch_from_local(doc_id: &str, persistence: Arc<Persistence>) -> DocRes
let data = op.get_data();
if !data.ends_with("\n") {
log::error!("The op must end with newline");
log::debug!("Invalid delta: {}", delta.to_json());
}
},
}

View File

@ -39,6 +39,10 @@ impl WorkspaceController {
trash_can: Arc<TrashCan>,
server: Server,
) -> Self {
if let Ok(token) = user.token() {
INIT_WORKSPACE.write().insert(token, false);
}
let workspace_sql = Arc::new(WorkspaceTableSql {});
Self {
user,
@ -52,11 +56,13 @@ impl WorkspaceController {
}
async fn init(&self, token: &str) -> Result<(), WorkspaceError> {
log::debug!("Start initializing workspace");
if let Some(is_init) = INIT_WORKSPACE.read().get(token) {
if *is_init {
return Ok(());
}
}
log::debug!("Finish initializing workspace");
INIT_WORKSPACE.write().insert(token.to_owned(), true);
let _ = self.server.init();
let _ = self.trash_can.init()?;