From 7f7fd4958f78b1546cdf28b01c9288d802ce876b Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 14 Aug 2023 21:38:30 +0700 Subject: [PATCH] feat: support deeplink on Linux --- .../lib/startup/tasks/supabase_task.dart | 18 +++++--- frontend/appflowy_flutter/pubspec.lock | 42 ++++++++++--------- frontend/appflowy_flutter/pubspec.yaml | 17 ++++++-- .../flatpack-buildfiles/dbus-interface.xml | 16 +++++++ .../io.appflowy.AppFlowy.desktop | 2 + .../io.appflowy.AppFlowy.launcher.desktop | 5 +++ .../io.appflowy.AppFlowy.service | 3 ++ .../scripts/flatpack-buildfiles/launcher.sh | 4 ++ 8 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 frontend/scripts/flatpack-buildfiles/dbus-interface.xml create mode 100644 frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.launcher.desktop create mode 100644 frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.service create mode 100644 frontend/scripts/flatpack-buildfiles/launcher.sh diff --git a/frontend/appflowy_flutter/lib/startup/tasks/supabase_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/supabase_task.dart index b2b881d2e7..26d6014faf 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/supabase_task.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/supabase_task.dart @@ -32,11 +32,6 @@ class InitSupabaseTask extends LaunchTask { return; } - // register deep link for Windows - if (Platform.isWindows) { - registerProtocolHandler(appflowyDeepLinkSchema); - } - supabase?.dispose(); supabase = null; final initializedSupabase = await Supabase.initialize( @@ -47,6 +42,19 @@ class InitSupabaseTask extends LaunchTask { ); realtimeService = SupbaseRealtimeService(supabase: initializedSupabase); supabase = initializedSupabase; + + if (Platform.isWindows) { + // register deep link for Windows + registerProtocolHandler(appflowyDeepLinkSchema); + } else if (Platform.isLinux) { + // register deep link for Linux + await SupabaseAuth.instance.registerDBusService( + // these values should be compatible with the values in the desktop file + // dbus-interface.xml + '/io/appflowy/AppFlowy/Object', + 'io.appflowy.AppFlowy', + ); + } } } diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index 1857ce52df..9d05c3019e 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -26,12 +26,13 @@ packages: source: hosted version: "2.0.7" app_links: - dependency: transitive + dependency: "direct overridden" description: - name: app_links - sha256: "16725e716afd0634a5441654b1dda2b6c5557aa230884b5e1f41a5aa546a4cb6" - url: "https://pub.dev" - source: hosted + path: "." + ref: f897e1d + resolved-ref: f897e1d81a3d9fcea632588479bc2814d493f7b5 + url: "https://github.com/LucasXu0/app_links" + source: git version: "3.4.3" appflowy_backend: dependency: "direct main" @@ -615,10 +616,10 @@ packages: dependency: transitive description: name: gotrue - sha256: "214d5050a68ce68a55da1a6d9d7a2e07e039b359f99f1a17ec685320c9101aa6" + sha256: "6ba95e38c06af30d4a365112b433567df70f83d5853923274cb894ea9702c5fa" url: "https://pub.dev" source: hosted - version: "1.8.4" + version: "1.11.2" graphs: dependency: transitive description: @@ -1036,10 +1037,10 @@ packages: dependency: transitive description: name: postgrest - sha256: "78fd180ecd2274df7b04c406746495b5c627248856458f8f537bf5348de9c817" + sha256: d6cc0f60c7dc761f84d1c6d11d9e02b3ad90399bd84639a28c1c024adbaa9bde url: "https://pub.dev" source: hosted - version: "1.3.2" + version: "1.5.0" process: dependency: transitive description: @@ -1084,10 +1085,10 @@ packages: dependency: transitive description: name: realtime_client - sha256: "0342f73f42345f3547e3cdcc804a0ed108fcd9142d1537d159aead94a213e248" + sha256: ff743de9bb0f46fcfffcfe64ae93062702dcd0f83a2ce8adc40d5fb7f542af90 url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.3" reorderables: dependency: "direct main" description: @@ -1409,18 +1410,19 @@ packages: dependency: transitive description: name: supabase - sha256: "5f5e47fcac99a496e15274d5f6944e1323519df9f8929b4ab9eef8711abeb5f3" + sha256: "291e065aa8c9be06a0348743c184beafd038e109960bc3da201affd3eda811fc" url: "https://pub.dev" source: hosted - version: "1.9.4" + version: "1.10.0" supabase_flutter: dependency: "direct main" description: - name: supabase_flutter - sha256: "1ebe89b83b992123d40dcf5aa88b87d6c2d0a3c62052380cfc94de2337aac469" - url: "https://pub.dev" - source: hosted - version: "1.10.4" + path: "packages/supabase_flutter" + ref: e882842 + resolved-ref: e8828421720896c0e1600de18f0db54f9f96a3b3 + url: "https://github.com/LucasXu0/supabase-flutter" + source: git + version: "1.10.12" sync_http: dependency: transitive description: @@ -1521,10 +1523,10 @@ packages: dependency: transitive description: name: universal_io - sha256: "06866290206d196064fd61df4c7aea1ffe9a4e7c4ccaa8fcded42dd41948005d" + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.2" universal_platform: dependency: transitive description: diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index d64f88b174..cf3c5c2e7e 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -105,9 +105,6 @@ dependencies: envied: ^0.3.0+3 dotted_border: ^2.0.0+3 url_protocol: - git: - url: https://github.com/LucasXu0/flutter_url_protocol.git - commit: 77a8420 hive: ^2.2.3 hive_flutter: ^1.1.0 @@ -130,6 +127,20 @@ dev_dependencies: dependency_overrides: http: ^1.0.0 + supabase_flutter: + git: + url: https://github.com/LucasXu0/supabase-flutter + ref: e882842 + path: packages/supabase_flutter + app_links: + git: + url: https://github.com/LucasXu0/app_links + ref: f897e1d + url_protocol: + git: + url: https://github.com/LucasXu0/flutter_url_protocol.git + commit: 77a8420 + # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your diff --git a/frontend/scripts/flatpack-buildfiles/dbus-interface.xml b/frontend/scripts/flatpack-buildfiles/dbus-interface.xml new file mode 100644 index 0000000000..a973b4bc4d --- /dev/null +++ b/frontend/scripts/flatpack-buildfiles/dbus-interface.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.desktop b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.desktop index 8b51c0c2ea..f8f2c06842 100644 --- a/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.desktop +++ b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.desktop @@ -5,3 +5,5 @@ Icon=io.appflowy.AppFlowy Exec=env GDK_GL=gles AppFlowy %U Categories=Network;Productivity; Keywords=Notes +DBusActivatable=true +Implements=io.appflowy.Appflowy; \ No newline at end of file diff --git a/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.launcher.desktop b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.launcher.desktop new file mode 100644 index 0000000000..7b2366372d --- /dev/null +++ b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.launcher.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=AppFlowy Launcher +Exec=launcher.sh %u +MimeType=x-scheme-handler/appflowy-flutter; diff --git a/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.service b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.service new file mode 100644 index 0000000000..31e32415d0 --- /dev/null +++ b/frontend/scripts/flatpack-buildfiles/io.appflowy.AppFlowy.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=io.appflowy.AppFlowy +Exec=AppFlowy diff --git a/frontend/scripts/flatpack-buildfiles/launcher.sh b/frontend/scripts/flatpack-buildfiles/launcher.sh new file mode 100644 index 0000000000..c7e7b9ee4a --- /dev/null +++ b/frontend/scripts/flatpack-buildfiles/launcher.sh @@ -0,0 +1,4 @@ +#!/bin/bash +gdbus call --session --dest io.appflowy.AppFlowy \ + --object-path /io/appflowy/AppFlowy/Object \ + --method io.appflowy.AppFlowy.Open "['$1']" {}