An open-source cross-platform alternative to AirDrop
refactor: remove platform checks in macos_channel.dart (#1813)
Shlomo15c416b4e5d3
diff --git a/app/lib/util/native/macos_channel.dart b/app/lib/util/native/macos_channel.dartindex 998fa473..5a8a7adb 100644--- a/app/lib/util/native/macos_channel.dart+++ b/app/lib/util/native/macos_channel.dart@@ -1,6 +1,5 @@import 'dart:async';-import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/util/native/taskbar_helper.dart';@@ -9,10 +8,6 @@ import 'package:localsend_app/util/native/tray_helper.dart';const _methodChannel = MethodChannel('main-delegate-channel');Future<void> setupStatusBar() async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return;- }-await _methodChannel.invokeMethod('setupStatusBar', {'open': t.tray.open,'quit': t.tray.close,@@ -20,58 +15,30 @@ Future<void> setupStatusBar() async {}Future<void> updateDockProgress(double progress) async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return;- }-await _methodChannel.invokeMethod('updateDockProgress', progress);}Future<void> setLaunchAtLogin(bool value) async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return;- }-await _methodChannel.invokeMethod('setLaunchAtLogin', value);}Future<bool> getLaunchAtLogin() async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return false;- }-return await _methodChannel.invokeMethod('getLaunchAtLogin');}Future<void> setLaunchAtLoginMinimized(bool value) async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return;- }-await _methodChannel.invokeMethod('setLaunchAtLoginMinimized', value);}Future<bool> getLaunchAtLoginMinimized() async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return false;- }-return await _methodChannel.invokeMethod('getLaunchAtLoginMinimized');}Future<bool> isLaunchedAsLoginItem() async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return false;- }-return await _methodChannel.invokeMethod('isLaunchedAsLoginItem');}Future<void> setDockIcon(TaskbarIcon icon) async {- if (defaultTargetPlatform != TargetPlatform.macOS) {- return;- }-await _methodChannel.invokeMethod('setDockIcon', icon.index);}diff --git a/app/macos/Runner/AppDelegate.swift b/app/macos/Runner/AppDelegate.swiftindex 04c3e832..acb2f8e5 100644--- a/app/macos/Runner/AppDelegate.swift+++ b/app/macos/Runner/AppDelegate.swift@@ -15,7 +15,7 @@ extension LaunchAtLogin {Whether the app was launched at login (i.e. as login items).- Important: This property must only be checked in `NSApplicationDelegate#applicationDidFinishLaunching` method, otherwise the `NSAppleEventManager.shared().currentAppleEvent` will be `nil`.- Source: https://stackoverflow.com/a/19890943- - Note: When we drop macOS 12 support and move to LaunchAtLogin-Modern package, this extension should be removed as it's ialready included - https://github.com/sindresorhus/LaunchAtLogin-Modern/blob/a04ec1c363be3627734f6dad757d82f5d4fa8fcc/Sources/LaunchAtLogin/LaunchAtLogin.swift#L34-L44+ - Note: When we drop macOS 12 support and move to LaunchAtLogin-Modern package, this extension should be removed as it's already included - https://github.com/sindresorhus/LaunchAtLogin-Modern/blob/a04ec1c363be3627734f6dad757d82f5d4fa8fcc/Sources/LaunchAtLogin/LaunchAtLogin.swift#L34-L44*/public static var wasLaunchedAtLogin: Bool {guard let event = NSAppleEventManager.shared().currentAppleEvent else { return false }