From a3cf68c4fef24f766ad03e68c31bb2eec175c466 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Sun, 24 Dec 2023 08:02:04 +0100 Subject: [PATCH] Fix embed feature --- app/lib/embed/action_web.dart | 11 +++++------ app/lib/views/main.dart | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/lib/embed/action_web.dart b/app/lib/embed/action_web.dart index 31b934adbadc..2a72222b734d 100644 --- a/app/lib/embed/action_web.dart +++ b/app/lib/embed/action_web.dart @@ -1,7 +1,6 @@ // ignore_for_file: avoid_web_libraries_in_flutter import 'dart:html'; -import 'dart:js_util'; import 'package:js/js.dart'; @@ -17,19 +16,19 @@ void setup() { } void pushMessage(String type, [Object? message]) { - window.dispatchEvent(CustomEvent('receive', - detail: jsify({'type': type, 'message': message}))); + window.dispatchEvent( + MessageEvent('receive', data: {'type': type, 'message': message})); } void sendEmbedMessage(String type, [Object? message]) { window.dispatchEvent( - CustomEvent('message', detail: {'type': type, 'message': message})); + MessageEvent('message', data: {'type': type, 'message': message})); } EventListener onEmbedMessage(String type, EmbedMessageHandler callback) { void listener(event) { - if (event is CustomEvent && event.detail?.type == type) { - callback(event.detail.message); + if (event is MessageEvent && event.data?.type == type) { + callback(event.data.message); } } diff --git a/app/lib/views/main.dart b/app/lib/views/main.dart index 9fc5e13c7709..dfdd56b09f3c 100644 --- a/app/lib/views/main.dart +++ b/app/lib/views/main.dart @@ -155,6 +155,8 @@ class _ProjectPageState extends State { ); _bloc?.load(); embedding.handler.register(context, _bloc!); + _importService = ImportService(context, _bloc); + _exportService = ExportService(context, _bloc); }); return; }