mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 06:22:34 +01:00
fix: Linux notification not showing when room is open but window in background
This commit is contained in:
parent
df98254640
commit
2a9fde6b35
@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:desktop_lifecycle/desktop_lifecycle.dart';
|
||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@ -17,7 +18,10 @@ import 'package:fluffychat/widgets/matrix.dart';
|
||||
extension LocalNotificationsExtension on MatrixState {
|
||||
void showLocalNotification(EventUpdate eventUpdate) async {
|
||||
final roomId = eventUpdate.roomID;
|
||||
if (webHasFocus && activeRoomId == roomId) return;
|
||||
if (activeRoomId == roomId) {
|
||||
if (kIsWeb && webHasFocus) return;
|
||||
if (Platform.isLinux && DesktopLifecycle.instance.isActive.value) return;
|
||||
}
|
||||
final room = client.getRoomById(roomId);
|
||||
if (room == null) {
|
||||
Logs().w('Can not display notification for unknown room $roomId');
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <desktop_drop/desktop_drop_plugin.h>
|
||||
#include <desktop_lifecycle/desktop_lifecycle_plugin.h>
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
@ -15,6 +16,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) desktop_drop_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin");
|
||||
desktop_drop_plugin_register_with_registrar(desktop_drop_registrar);
|
||||
g_autoptr(FlPluginRegistrar) desktop_lifecycle_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopLifecyclePlugin");
|
||||
desktop_lifecycle_plugin_register_with_registrar(desktop_lifecycle_registrar);
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
desktop_drop
|
||||
desktop_lifecycle
|
||||
file_selector_linux
|
||||
flutter_secure_storage_linux
|
||||
url_launcher_linux
|
||||
|
@ -316,6 +316,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.2"
|
||||
desktop_lifecycle:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: desktop_lifecycle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
desktop_notifications:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -20,6 +20,7 @@ dependencies:
|
||||
connectivity_plus: ^2.2.0
|
||||
cupertino_icons: any
|
||||
desktop_drop: ^0.3.2
|
||||
desktop_lifecycle: ^0.1.0
|
||||
desktop_notifications: ^0.6.3
|
||||
device_info_plus: ^3.2.1
|
||||
email_validator: ^2.0.1
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <connectivity_plus_windows/connectivity_plus_windows_plugin.h>
|
||||
#include <desktop_drop/desktop_drop_plugin.h>
|
||||
#include <desktop_lifecycle/desktop_lifecycle_plugin.h>
|
||||
#include <file_selector_windows/file_selector_plugin.h>
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
|
||||
@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
DesktopDropPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
|
||||
DesktopLifecyclePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopLifecyclePlugin"));
|
||||
FileSelectorPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorPlugin"));
|
||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||
|
@ -5,6 +5,7 @@
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
connectivity_plus_windows
|
||||
desktop_drop
|
||||
desktop_lifecycle
|
||||
file_selector_windows
|
||||
flutter_secure_storage_windows
|
||||
flutter_webrtc
|
||||
|
Loading…
Reference in New Issue
Block a user