fix notification click did not directly open the chats

This commit is contained in:
otsmr 2026-06-19 17:04:09 +02:00
parent 0007ba62a0
commit 26c9dc0066
4 changed files with 36 additions and 51 deletions

View file

@ -74,6 +74,7 @@ void main() async {
var storageError = await twonlyMinimumInitialization();
await FcmNotificationService.initStartup();
await setupPushNotification();
var userExists = false;
@ -163,7 +164,6 @@ Future<void> postStartupTasks() async {
unawaited(MediaFileService.purgeTempFolder());
// 2. Service initializations
unawaited(setupPushNotification());
unawaited(finishStartedPreprocessing());
unawaited(createPushAvatars());

View file

@ -159,6 +159,7 @@ Future<void> showLocalPushNotification(
ticker: 'You got a new message.',
largeIcon: styleInformation,
icon: 'ic_launcher_foreground',
groupKey: 'com.twonly.messages',
);
const darwinNotificationDetails = DarwinNotificationDetails();
@ -190,44 +191,30 @@ Future<void> showLocalPushNotification(
notificationDetails,
payload: payload,
);
}
Future<void> showLocalPushNotificationWithoutUserId(
PushNotification pushNotification,
) async {
final lang = getLocalizations();
var title = lang.notificationTitleUnknown;
var body = lang.notificationBodyUnknown;
if (pushNotification.kind == PushKind.CONTACT_REQUEST) {
title = lang.you;
body = lang.notificationContactRequestUnknownUser;
}
final androidNotificationDetails = AndroidNotificationDetails(
if (Platform.isAndroid) {
final summaryAndroidDetails = AndroidNotificationDetails(
'0',
lang.notificationCategoryMessageTitle,
channelDescription: lang.notificationCategoryMessageDesc,
importance: Importance.max,
priority: Priority.max,
ticker: 'You got a new message.',
groupKey: 'com.twonly.messages',
setAsGroupSummary: true,
icon: 'ic_launcher_foreground',
);
const darwinNotificationDetails = DarwinNotificationDetails();
final notificationDetails = NotificationDetails(
android: androidNotificationDetails,
iOS: darwinNotificationDetails,
final summaryNotificationDetails = NotificationDetails(
android: summaryAndroidDetails,
);
await flutterLocalNotificationsPlugin.show(
2,
title,
body,
notificationDetails,
payload: pushNotification.kind.name,
0,
lang.notificationCategoryMessageTitle,
'',
summaryNotificationDetails,
payload: Routes.chats,
);
}
}
Future<String?> getAvatarIcon(int contactId) async {
final avatarsDirectory = Directory('${AppEnvironment.cacheDir}/avatars');

View file

@ -197,17 +197,15 @@ class MainCameraController {
if (!isVideoRecording) {
await cameraController?.stopImageStream();
}
} catch (e) {
Log.info(e);
}
if (cameraController == null) return;
selectedCameraDetails.scaleFactor = 1;
await cameraController?.setZoomLevel(1);
if (cameraController == null) return;
await cameraController?.setDescription(AppEnvironment.cameras[cameraId]);
await cameraController?.setDescription(
AppEnvironment.cameras[cameraId],
);
if (cameraController == null) return;
try {
if (!isVideoRecording) {
await cameraController?.startImageStream(_processCameraImage);
}
@ -462,7 +460,10 @@ class MainCameraController {
scannedUrl = link;
if (sharedLinkForPreview == null) {
timeSharedLinkWasSetWithQr = clock.now();
setSharedLinkForPreview(Uri.parse(scannedUrl!), generatePreview: false);
setSharedLinkForPreview(
Uri.parse(scannedUrl!),
generatePreview: false,
);
}
}
}

View file

@ -156,13 +156,10 @@ class HomeViewState extends State<HomeView> with WidgetsBindingObserver {
payload.startsWith(Routes.chats) &&
payload != Routes.chats) {
routerProvider.go(payload);
streamHomeViewPageIndex.add(0);
}
if (payload == Routes.chats) {
streamHomeViewPageIndex.add(0);
}
}
}
final draftMedia = await twonlyDB.mediaFilesDao.getDraftMediaFile();
if (draftMedia != null) {