chore: Follow up router fixes
This commit is contained in:
parent
0c69ce0552
commit
b7dac8365a
8 changed files with 54 additions and 67 deletions
|
|
@ -43,10 +43,13 @@ class FluffyChatApp extends StatelessWidget {
|
|||
localizationsDelegates: L10n.localizationsDelegates,
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
routerConfig: router,
|
||||
builder: (context, child) => Matrix(
|
||||
context: context,
|
||||
clients: clients,
|
||||
child: testWidget ?? child,
|
||||
builder: (context, child) => Navigator(
|
||||
onGenerateRoute: (_) => MaterialPageRoute(
|
||||
builder: (_) => Matrix(
|
||||
clients: clients,
|
||||
child: testWidget ?? child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -33,10 +33,9 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
if (room.notificationCount == 0) return;
|
||||
|
||||
final event = Event.fromJson(eventUpdate.content, room);
|
||||
final title =
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(navigatorContext)!));
|
||||
final title = room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!));
|
||||
final body = await event.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(navigatorContext)!),
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
withSenderNamePrefix:
|
||||
!room.isDirectChat || room.lastEvent?.senderId == client.userID,
|
||||
plaintextBody: true,
|
||||
|
|
@ -95,11 +94,11 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
actions: [
|
||||
NotificationAction(
|
||||
DesktopNotificationActions.openChat.name,
|
||||
L10n.of(navigatorContext)!.openChat,
|
||||
L10n.of(context)!.openChat,
|
||||
),
|
||||
NotificationAction(
|
||||
DesktopNotificationActions.seen.name,
|
||||
L10n.of(navigatorContext)!.markAsRead,
|
||||
L10n.of(context)!.markAsRead,
|
||||
),
|
||||
],
|
||||
hints: [
|
||||
|
|
@ -114,7 +113,7 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
room.setReadMarker(event.eventId, mRead: event.eventId);
|
||||
break;
|
||||
case DesktopNotificationActions.openChat:
|
||||
navigatorContext.go(['', 'rooms', room.id].join('/'));
|
||||
context.go(['', 'rooms', room.id].join('/'));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import 'package:collection/collection.dart';
|
|||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:matrix/encryption.dart';
|
||||
|
|
@ -24,6 +23,7 @@ import 'package:fluffychat/utils/localized_exception_extension.dart';
|
|||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/uia_request_manager.dart';
|
||||
import 'package:fluffychat/utils/voip_plugin.dart';
|
||||
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
||||
import '../config/app_config.dart';
|
||||
import '../config/setting_keys.dart';
|
||||
import '../pages/key_verification/key_verification_dialog.dart';
|
||||
|
|
@ -37,16 +37,12 @@ import 'local_notifications_extension.dart';
|
|||
class Matrix extends StatefulWidget {
|
||||
final Widget? child;
|
||||
|
||||
@Deprecated('')
|
||||
final BuildContext context;
|
||||
|
||||
final List<Client> clients;
|
||||
|
||||
final Map<String, String>? queryParameters;
|
||||
|
||||
const Matrix({
|
||||
this.child,
|
||||
required this.context,
|
||||
required this.clients,
|
||||
this.queryParameters,
|
||||
Key? key,
|
||||
|
|
@ -64,7 +60,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
int _activeClient = -1;
|
||||
String? activeBundle;
|
||||
Store store = Store();
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
HomeserverSummary? loginHomeserverSummary;
|
||||
XFile? loginAvatar;
|
||||
|
|
@ -172,7 +167,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
ClientManager.addClientNameToStore(_loginClientCandidate!.clientName);
|
||||
_registerSubs(_loginClientCandidate!.clientName);
|
||||
_loginClientCandidate = null;
|
||||
navigatorContext.go('/rooms');
|
||||
FluffyChatApp.router.go('/rooms');
|
||||
});
|
||||
return candidate;
|
||||
}
|
||||
|
|
@ -239,8 +234,11 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
|
||||
bool webHasFocus = true;
|
||||
|
||||
String? get activeRoomId =>
|
||||
GoRouterState.of(navigatorContext).pathParameters['roomid'];
|
||||
String? get activeRoomId {
|
||||
final route = FluffyChatApp.router.routeInformationProvider.value.location;
|
||||
if (route == null || !route.startsWith('/rooms/')) return null;
|
||||
return route.split('/')[2];
|
||||
}
|
||||
|
||||
final linuxNotifications =
|
||||
PlatformInfos.isLinux ? NotificationsClient() : null;
|
||||
|
|
@ -309,13 +307,13 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
if (!hidPopup &&
|
||||
{KeyVerificationState.done, KeyVerificationState.error}
|
||||
.contains(request.state)) {
|
||||
Navigator.of(navigatorContext).pop('dialog');
|
||||
Navigator.of(context).pop('dialog');
|
||||
}
|
||||
hidPopup = true;
|
||||
};
|
||||
request.onUpdate = null;
|
||||
hidPopup = true;
|
||||
await KeyVerificationDialog(request: request).show(navigatorContext);
|
||||
await KeyVerificationDialog(request: request).show(context);
|
||||
});
|
||||
onLoginStateChanged[name] ??= c.onLoginStateChanged.stream.listen((state) {
|
||||
final loggedInWithMultipleClients = widget.clients.length > 1;
|
||||
|
|
@ -330,16 +328,11 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
);
|
||||
|
||||
if (state != LoginState.loggedIn) {
|
||||
navigatorContext.go(
|
||||
Uri(
|
||||
path: '/rooms',
|
||||
queryParameters:
|
||||
GoRouterState.of(navigatorContext).uri.queryParameters,
|
||||
).toString(),
|
||||
);
|
||||
FluffyChatApp.router.go('/rooms');
|
||||
}
|
||||
} else {
|
||||
navigatorContext.go(state == LoginState.loggedIn ? '/rooms' : '/home');
|
||||
FluffyChatApp.router
|
||||
.go(state == LoginState.loggedIn ? '/rooms' : '/home');
|
||||
}
|
||||
});
|
||||
onUiaRequest[name] ??= c.onUiaRequest.stream.listen(uiaRequestHandler);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue