mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
Merge latest PR #1524 into 2.0.0-beta.2
This commit is contained in:
commit
534fbbb3a2
2 files changed
+46
-4
No files matched your search
@@ -252,10 +252,7 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
|||||||
await bringWindowToFront();
|
await bringWindowToFront();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!await File(spec.path).exists()) {
|
// Use the task card's file operations, including reveal's parent fallback.
|
||||||
logger.w('notification target no longer exists: ${spec.path}');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (spec.id) {
|
switch (spec.id) {
|
||||||
case _openFileAction:
|
case _openFileAction:
|
||||||
if (!await openTaskFile(spec.path)) {
|
if (!await openTaskFile(spec.path)) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@@ -217,6 +218,50 @@ void main() {
|
|||||||
expect(notifier.frontedWindow, isFalse);
|
expect(notifier.frontedWindow, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('folder actions accept an existing BT directory on all desktop payload formats', () async {
|
||||||
|
final container = await start(enabled: true);
|
||||||
|
final notifier = container.read(appNotificationControllerProvider.notifier) as _TestNotificationController;
|
||||||
|
final directory = await Directory.systemTemp.createTemp('gopeed-notification-bt-');
|
||||||
|
addTearDown(() => directory.delete(recursive: true));
|
||||||
|
|
||||||
|
for (final windows in [true, false]) {
|
||||||
|
await notifier.handleNotificationResponse(
|
||||||
|
NotificationResponse(
|
||||||
|
notificationResponseType: NotificationResponseType.selectedNotificationAction,
|
||||||
|
actionId: windows
|
||||||
|
? NotificationActionSpec(id: 'open_folder', path: directory.path).encode()
|
||||||
|
: 'open_folder',
|
||||||
|
payload: windows ? null : jsonEncode({'path': directory.path}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(notifier.revealedFolders, [directory.path, directory.path]);
|
||||||
|
expect(notifier.openedFiles, isEmpty);
|
||||||
|
expect(notifier.frontedWindow, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('missing targets reach shared file operations so reveal can fall back to the parent', () async {
|
||||||
|
final container = await start(enabled: true);
|
||||||
|
final notifier = container.read(appNotificationControllerProvider.notifier) as _TestNotificationController;
|
||||||
|
final directory = await Directory.systemTemp.createTemp('gopeed-notification-parent-');
|
||||||
|
addTearDown(() => directory.delete(recursive: true));
|
||||||
|
final missingPath = '${directory.path}/removed.zip';
|
||||||
|
|
||||||
|
for (final action in ['open_file', 'open_folder']) {
|
||||||
|
await notifier.handleNotificationResponse(
|
||||||
|
NotificationResponse(
|
||||||
|
notificationResponseType: NotificationResponseType.selectedNotificationAction,
|
||||||
|
actionId: NotificationActionSpec(id: action, path: missingPath).encode(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(notifier.openedFiles, [missingPath]);
|
||||||
|
expect(notifier.revealedFolders, [missingPath]);
|
||||||
|
expect(notifier.frontedWindow, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
test('a plain notification body click brings the app window to the front', () async {
|
test('a plain notification body click brings the app window to the front', () async {
|
||||||
final container = await start(enabled: true);
|
final container = await start(enabled: true);
|
||||||
final notifier = container.read(appNotificationControllerProvider.notifier) as _TestNotificationController;
|
final notifier = container.read(appNotificationControllerProvider.notifier) as _TestNotificationController;
|
||||||
|
|||||||
Reference in new issue
Block a user