mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add icon field (#4824)
* feat: add icon field * fix: add sqlx migration files * chore: fix tst * chore: fix duplicate event name * chore: update to lastest stable rust toolchain * chore: use 1.75 channel * chore: fix duplicate event name * chore: fix duplicate event name * chore: use more reliable assertion --------- Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
@ -11,7 +11,7 @@ use crate::module::AFPluginStateMap;
|
||||
use crate::runtime::AFPluginRuntime;
|
||||
use crate::{
|
||||
errors::{DispatchError, Error, InternalError},
|
||||
module::{as_plugin_map, AFPlugin, AFPluginMap, AFPluginRequest},
|
||||
module::{plugin_map_or_crash, AFPlugin, AFPluginMap, AFPluginRequest},
|
||||
response::AFPluginEventResponse,
|
||||
service::{AFPluginServiceFactory, Service},
|
||||
};
|
||||
@ -87,7 +87,7 @@ impl AFPluginDispatcher {
|
||||
pub fn new(runtime: Arc<AFPluginRuntime>, plugins: Vec<AFPlugin>) -> AFPluginDispatcher {
|
||||
tracing::trace!("{}", plugin_info(&plugins));
|
||||
AFPluginDispatcher {
|
||||
plugins: as_plugin_map(plugins),
|
||||
plugins: plugin_map_or_crash(plugins),
|
||||
runtime,
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,16 @@ use crate::{
|
||||
};
|
||||
|
||||
pub type AFPluginMap = Arc<HashMap<AFPluginEvent, Arc<AFPlugin>>>;
|
||||
pub(crate) fn as_plugin_map(plugins: Vec<AFPlugin>) -> AFPluginMap {
|
||||
let mut plugin_map = HashMap::new();
|
||||
pub(crate) fn plugin_map_or_crash(plugins: Vec<AFPlugin>) -> AFPluginMap {
|
||||
let mut plugin_map: HashMap<AFPluginEvent, Arc<AFPlugin>> = HashMap::new();
|
||||
plugins.into_iter().for_each(|m| {
|
||||
let events = m.events();
|
||||
let plugins = Arc::new(m);
|
||||
events.into_iter().for_each(|e| {
|
||||
if plugin_map.contains_key(&e) {
|
||||
let plugin_name = plugin_map.get(&e).and_then(|p| Some(&p.name));
|
||||
panic!("⚠️⚠️⚠️Error: {:?} is already defined in {:?}", &e, plugin_name,);
|
||||
}
|
||||
plugin_map.insert(e, plugins.clone());
|
||||
});
|
||||
});
|
||||
@ -40,7 +44,7 @@ pub(crate) fn as_plugin_map(plugins: Vec<AFPlugin>) -> AFPluginMap {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct AFPluginEvent(pub String);
|
||||
pub struct AFPluginEvent(String);
|
||||
|
||||
impl<T: Display + Eq + Hash + Debug + Clone> std::convert::From<T> for AFPluginEvent {
|
||||
fn from(t: T) -> Self {
|
||||
|
Reference in New Issue
Block a user