2023-08-06 03:51:03 +00:00
|
|
|
use std::sync::Weak;
|
|
|
|
|
2023-05-17 08:33:44 +00:00
|
|
|
use strum_macros::Display;
|
|
|
|
|
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
2023-08-06 03:51:03 +00:00
|
|
|
use flowy_sqlite::kv::StorePreferences;
|
2023-05-17 08:33:44 +00:00
|
|
|
use lib_dispatch::prelude::AFPlugin;
|
|
|
|
|
|
|
|
use crate::event_handler::*;
|
|
|
|
|
2023-08-06 03:51:03 +00:00
|
|
|
pub fn init(store_preferences: Weak<StorePreferences>) -> AFPlugin {
|
2023-05-17 08:33:44 +00:00
|
|
|
AFPlugin::new()
|
|
|
|
.name(env!("CARGO_PKG_NAME"))
|
2023-08-06 03:51:03 +00:00
|
|
|
.state(store_preferences)
|
2023-05-17 08:33:44 +00:00
|
|
|
.event(ConfigEvent::SetKeyValue, set_key_value_handler)
|
|
|
|
.event(ConfigEvent::GetKeyValue, get_key_value_handler)
|
|
|
|
.event(ConfigEvent::RemoveKeyValue, remove_key_value_handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Display, ProtoBuf_Enum, Flowy_Event)]
|
|
|
|
#[event_err = "FlowyError"]
|
|
|
|
pub enum ConfigEvent {
|
|
|
|
#[event(input = "KeyValuePB")]
|
|
|
|
SetKeyValue = 0,
|
|
|
|
|
|
|
|
#[event(input = "KeyPB", output = "KeyValuePB")]
|
|
|
|
GetKeyValue = 1,
|
|
|
|
|
|
|
|
#[event(input = "KeyPB")]
|
|
|
|
RemoveKeyValue = 2,
|
|
|
|
}
|