Bartosz Sypytkowski fd5299a13d
move to latest appflowy collab version (#5894)
* chore: move to latest appflowy collab version

* chore: filter mapping

* chore: remove mutex folder

* chore: cleanup borrow checker issues

* chore: fixed flowy user crate compilation errors

* chore: removed parking lot crate

* chore: adjusting non locking approach

* chore: remove with folder method

* chore: fix folder manager

* chore: fixed workspace database compilation errors

* chore: initialize database plugins

* chore: fix locks in flowy core

* chore: remove supabase

* chore: async traits

* chore: add mutexes in dart ffi

* chore: post rebase fixes

* chore: remove supabase dart code

* chore: fix deadlock

* chore: fix page_id is empty

* chore: use data source to init collab

* chore: fix user awareness test

* chore: fix database deadlock

* fix: initialize user awareness

* chore: fix open workspace test

* chore: fix import csv

* chore: fix update row meta deadlock

* chore: fix document size test

* fix: timestamp set/get type convert

* fix: calculation

* chore: revert Arc to Rc

* chore: attach plugin to database and database row

* chore: async get row

* chore: clippy

* chore: fix tauri build

* chore: clippy

* fix: duplicate view deadlock

* chore: fmt

* chore: tauri build

---------

Co-authored-by: nathan <nathan@appflowy.io>
2024-08-18 11:16:42 +08:00

49 lines
1.4 KiB
Rust

use std::sync::Arc;
use flowy_error::{FlowyError, FlowyResult};
use crate::entities::FieldType;
use crate::services::database::DatabaseEditor;
use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOption, TypeOption};
pub async fn edit_field_type_option<T: TypeOption>(
field_id: &str,
editor: Arc<DatabaseEditor>,
action: impl FnOnce(&mut T),
) -> FlowyResult<()> {
let field = editor
.get_field(field_id)
.await
.ok_or_else(FlowyError::field_record_not_found)?;
let field_type = FieldType::from(field.field_type);
let get_type_option = field.get_type_option::<T>(field_type);
if let Some(mut type_option) = get_type_option {
if let Some(old_field) = editor.get_field(field_id).await {
action(&mut type_option);
let type_option_data = type_option.into();
editor
.update_field_type_option(field_id, type_option_data, old_field)
.await?;
}
}
Ok(())
}
pub async fn edit_single_select_type_option(
field_id: &str,
editor: Arc<DatabaseEditor>,
action: impl FnOnce(&mut SingleSelectTypeOption),
) -> FlowyResult<()> {
edit_field_type_option(field_id, editor, action).await
}
pub async fn edit_multi_select_type_option(
field_id: &str,
editor: Arc<DatabaseEditor>,
action: impl FnOnce(&mut MultiSelectTypeOption),
) -> FlowyResult<()> {
edit_field_type_option(field_id, editor, action).await
}