revert changes for test
This commit is contained in:
@@ -178,7 +178,6 @@ Future<T> _init<T>(
|
|||||||
Future<T> Function() initializer, {
|
Future<T> Function() initializer, {
|
||||||
int? timeout,
|
int? timeout,
|
||||||
}) async {
|
}) async {
|
||||||
Logger.bootstrap.warning("$name starting seconds");
|
|
||||||
final stopWatch = Stopwatch()..start();
|
final stopWatch = Stopwatch()..start();
|
||||||
Logger.bootstrap.info("initializing [$name]");
|
Logger.bootstrap.info("initializing [$name]");
|
||||||
Future<T> func() => timeout != null
|
Future<T> func() => timeout != null
|
||||||
@@ -188,20 +187,13 @@ Future<T> _init<T>(
|
|||||||
final result = await func();
|
final result = await func();
|
||||||
Logger.bootstrap
|
Logger.bootstrap
|
||||||
.debug("[$name] initialized in ${stopWatch.elapsedMilliseconds}ms");
|
.debug("[$name] initialized in ${stopWatch.elapsedMilliseconds}ms");
|
||||||
|
|
||||||
Logger.bootstrap.warning("$name done successfully waiting 2 seconds");
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
|
||||||
return result;
|
return result;
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
Logger.bootstrap.error("[$name] error initializing", e, stackTrace);
|
Logger.bootstrap.error("[$name] error initializing", e, stackTrace);
|
||||||
Logger.bootstrap.warning("$name done with error waiting 2 seconds");
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
|
||||||
rethrow;
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
}
|
}
|
||||||
Logger.bootstrap.warning("$name done with unknown state waiting 2 seconds");
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T?> _safeInit<T>(
|
Future<T?> _safeInit<T>(
|
||||||
|
|||||||
@@ -13,24 +13,21 @@ class DeepLinkNotifier extends _$DeepLinkNotifier
|
|||||||
with ProtocolListener, InfraLogger {
|
with ProtocolListener, InfraLogger {
|
||||||
@override
|
@override
|
||||||
Future<NewProfileLink?> build() async {
|
Future<NewProfileLink?> build() async {
|
||||||
// if (Platform.isLinux) return null;
|
if (Platform.isLinux) return null;
|
||||||
try {
|
|
||||||
for (final protocol in LinkParser.protocols) {
|
|
||||||
await protocolHandler.register(protocol);
|
|
||||||
}
|
|
||||||
protocolHandler.addListener(this);
|
|
||||||
ref.onDispose(() {
|
|
||||||
protocolHandler.removeListener(this);
|
|
||||||
});
|
|
||||||
|
|
||||||
final initialPayload = await protocolHandler.getInitialUrl();
|
for (final protocol in LinkParser.protocols) {
|
||||||
if (initialPayload != null) {
|
await protocolHandler.register(protocol);
|
||||||
loggy.debug('initial payload: [$initialPayload]');
|
}
|
||||||
final link = LinkParser.deep(initialPayload);
|
protocolHandler.addListener(this);
|
||||||
return link;
|
ref.onDispose(() {
|
||||||
}
|
protocolHandler.removeListener(this);
|
||||||
} catch (e) {
|
});
|
||||||
loggy.error("failed to init deeplink", e);
|
|
||||||
|
final initialPayload = await protocolHandler.getInitialUrl();
|
||||||
|
if (initialPayload != null) {
|
||||||
|
loggy.debug('initial payload: [$initialPayload]');
|
||||||
|
final link = LinkParser.deep(initialPayload);
|
||||||
|
return link;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,111 +19,107 @@ part 'system_tray_notifier.g.dart';
|
|||||||
class SystemTrayNotifier extends _$SystemTrayNotifier with AppLogger {
|
class SystemTrayNotifier extends _$SystemTrayNotifier with AppLogger {
|
||||||
@override
|
@override
|
||||||
Future<void> build() async {
|
Future<void> build() async {
|
||||||
if (true) return;
|
|
||||||
if (!PlatformUtils.isDesktop) return;
|
if (!PlatformUtils.isDesktop) return;
|
||||||
|
|
||||||
|
await trayManager.setIcon(
|
||||||
|
_trayIconPath,
|
||||||
|
isTemplate: Platform.isMacOS,
|
||||||
|
);
|
||||||
|
if (!Platform.isLinux) await trayManager.setToolTip(Constants.appName);
|
||||||
|
|
||||||
|
ConnectionStatus connection;
|
||||||
try {
|
try {
|
||||||
await trayManager.setIcon(
|
connection = await ref.watch(connectionNotifierProvider.future);
|
||||||
_trayIconPath,
|
|
||||||
isTemplate: Platform.isMacOS,
|
|
||||||
);
|
|
||||||
if (!Platform.isLinux) await trayManager.setToolTip(Constants.appName);
|
|
||||||
|
|
||||||
ConnectionStatus connection;
|
|
||||||
try {
|
|
||||||
connection = await ref.watch(connectionNotifierProvider.future);
|
|
||||||
} catch (e) {
|
|
||||||
loggy.warning("error getting connection status", e);
|
|
||||||
connection = const ConnectionStatus.disconnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
final serviceMode = ref.watch(ConfigOptions.serviceMode);
|
|
||||||
|
|
||||||
final t = ref.watch(translationsProvider);
|
|
||||||
final destinations = <(String label, String location)>[
|
|
||||||
(t.home.pageTitle, const HomeRoute().location),
|
|
||||||
(t.proxies.pageTitle, const ProxiesRoute().location),
|
|
||||||
(t.logs.pageTitle, const LogsOverviewRoute().location),
|
|
||||||
(t.settings.pageTitle, const SettingsRoute().location),
|
|
||||||
(t.about.pageTitle, const AboutRoute().location),
|
|
||||||
];
|
|
||||||
|
|
||||||
loggy.debug('updating system tray');
|
|
||||||
|
|
||||||
final menu = Menu(
|
|
||||||
items: [
|
|
||||||
MenuItem(
|
|
||||||
label: t.tray.dashboard,
|
|
||||||
onClick: (_) async {
|
|
||||||
await ref.read(windowNotifierProvider.notifier).open();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
MenuItem.separator(),
|
|
||||||
MenuItem.checkbox(
|
|
||||||
label: switch (connection) {
|
|
||||||
Disconnected() => t.tray.status.connect,
|
|
||||||
Connecting() => t.tray.status.connecting,
|
|
||||||
Connected() => t.tray.status.disconnect,
|
|
||||||
Disconnecting() => t.tray.status.disconnecting,
|
|
||||||
},
|
|
||||||
checked: connection.isConnected,
|
|
||||||
disabled: connection.isSwitching,
|
|
||||||
onClick: (_) async {
|
|
||||||
await ref
|
|
||||||
.read(connectionNotifierProvider.notifier)
|
|
||||||
.toggleConnection();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
MenuItem.submenu(
|
|
||||||
label: t.config.serviceMode,
|
|
||||||
submenu: Menu(
|
|
||||||
items: [
|
|
||||||
...ServiceMode.values.map(
|
|
||||||
(e) => MenuItem.checkbox(
|
|
||||||
checked: e == serviceMode,
|
|
||||||
key: e.name,
|
|
||||||
label: e.present(t),
|
|
||||||
onClick: (menuItem) async {
|
|
||||||
final newMode = ServiceMode.values.byName(menuItem.key!);
|
|
||||||
loggy.debug("switching service mode: [$newMode]");
|
|
||||||
await ref
|
|
||||||
.read(ConfigOptions.serviceMode.notifier)
|
|
||||||
.update(newMode);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MenuItem.submenu(
|
|
||||||
label: t.tray.open,
|
|
||||||
submenu: Menu(
|
|
||||||
items: [
|
|
||||||
...destinations.map(
|
|
||||||
(e) => MenuItem(
|
|
||||||
label: e.$1,
|
|
||||||
onClick: (_) async {
|
|
||||||
await ref.read(windowNotifierProvider.notifier).open();
|
|
||||||
ref.read(routerProvider).go(e.$2);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MenuItem.separator(),
|
|
||||||
MenuItem(
|
|
||||||
label: t.tray.quit,
|
|
||||||
onClick: (_) async {
|
|
||||||
return ref.read(windowNotifierProvider.notifier).quit();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
await trayManager.setContextMenu(menu);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
loggy.error("error updating system tray", e);
|
loggy.warning("error getting connection status", e);
|
||||||
|
connection = const ConnectionStatus.disconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final serviceMode = ref.watch(ConfigOptions.serviceMode);
|
||||||
|
|
||||||
|
final t = ref.watch(translationsProvider);
|
||||||
|
final destinations = <(String label, String location)>[
|
||||||
|
(t.home.pageTitle, const HomeRoute().location),
|
||||||
|
(t.proxies.pageTitle, const ProxiesRoute().location),
|
||||||
|
(t.logs.pageTitle, const LogsOverviewRoute().location),
|
||||||
|
(t.settings.pageTitle, const SettingsRoute().location),
|
||||||
|
(t.about.pageTitle, const AboutRoute().location),
|
||||||
|
];
|
||||||
|
|
||||||
|
loggy.debug('updating system tray');
|
||||||
|
|
||||||
|
final menu = Menu(
|
||||||
|
items: [
|
||||||
|
MenuItem(
|
||||||
|
label: t.tray.dashboard,
|
||||||
|
onClick: (_) async {
|
||||||
|
await ref.read(windowNotifierProvider.notifier).open();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
MenuItem.separator(),
|
||||||
|
MenuItem.checkbox(
|
||||||
|
label: switch (connection) {
|
||||||
|
Disconnected() => t.tray.status.connect,
|
||||||
|
Connecting() => t.tray.status.connecting,
|
||||||
|
Connected() => t.tray.status.disconnect,
|
||||||
|
Disconnecting() => t.tray.status.disconnecting,
|
||||||
|
},
|
||||||
|
checked: connection.isConnected,
|
||||||
|
disabled: connection.isSwitching,
|
||||||
|
onClick: (_) async {
|
||||||
|
await ref
|
||||||
|
.read(connectionNotifierProvider.notifier)
|
||||||
|
.toggleConnection();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
MenuItem.submenu(
|
||||||
|
label: t.config.serviceMode,
|
||||||
|
submenu: Menu(
|
||||||
|
items: [
|
||||||
|
...ServiceMode.values.map(
|
||||||
|
(e) => MenuItem.checkbox(
|
||||||
|
checked: e == serviceMode,
|
||||||
|
key: e.name,
|
||||||
|
label: e.present(t),
|
||||||
|
onClick: (menuItem) async {
|
||||||
|
final newMode = ServiceMode.values.byName(menuItem.key!);
|
||||||
|
loggy.debug("switching service mode: [$newMode]");
|
||||||
|
await ref
|
||||||
|
.read(ConfigOptions.serviceMode.notifier)
|
||||||
|
.update(newMode);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MenuItem.submenu(
|
||||||
|
label: t.tray.open,
|
||||||
|
submenu: Menu(
|
||||||
|
items: [
|
||||||
|
...destinations.map(
|
||||||
|
(e) => MenuItem(
|
||||||
|
label: e.$1,
|
||||||
|
onClick: (_) async {
|
||||||
|
await ref.read(windowNotifierProvider.notifier).open();
|
||||||
|
ref.read(routerProvider).go(e.$2);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MenuItem.separator(),
|
||||||
|
MenuItem(
|
||||||
|
label: t.tray.quit,
|
||||||
|
onClick: (_) async {
|
||||||
|
return ref.read(windowNotifierProvider.notifier).quit();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
await trayManager.setContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String get _trayIconPath {
|
static String get _trayIconPath {
|
||||||
|
|||||||
Reference in New Issue
Block a user