plugin_framework, handle plugin list
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
db71dd039d
commit
4eb6bd82a4
8 changed files with 57 additions and 33 deletions
|
|
@ -126,6 +126,7 @@ void runMainApp(bool startService) async {
|
|||
// await windowManager.ensureInitialized();
|
||||
gFFI.serverModel.startService();
|
||||
bind.pluginSyncUi(syncTo: kAppTypeMain);
|
||||
bind.pluginListReload();
|
||||
}
|
||||
gFFI.userModel.refreshCurrentUser();
|
||||
runApp(App());
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ class FfiModel with ChangeNotifier {
|
|||
} else if (name == 'fingerprint') {
|
||||
FingerprintState.find(peerId).value = evt['fingerprint'] ?? '';
|
||||
} else if (name == 'plugin_manager') {
|
||||
debugPrint('REMOVE ME ==================== plugin_manager $evt');
|
||||
pluginManager.handleEvent(evt);
|
||||
} else if (name == 'plugin_event') {
|
||||
handlePluginEvent(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// The plugin manager is a singleton class that manages the plugins.
|
||||
// 1. It merge metadata and the desc of plugins.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:collection';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -211,17 +212,19 @@ class PluginManager with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
void _handlePluginList(List<dynamic> evt) {
|
||||
void _handlePluginList(String pluginList) {
|
||||
_plugins.clear();
|
||||
|
||||
for (var p in evt) {
|
||||
final plugin = _getPluginFromEvent(p);
|
||||
if (plugin == null) {
|
||||
continue;
|
||||
try {
|
||||
for (var p in json.decode(pluginList) as List<dynamic>) {
|
||||
final plugin = _getPluginFromEvent(p);
|
||||
if (plugin == null) {
|
||||
continue;
|
||||
}
|
||||
_plugins.add(plugin);
|
||||
}
|
||||
_plugins.add(plugin);
|
||||
} catch (e) {
|
||||
debugPrint('Failed to decode plugin list \'$pluginList\'');
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue