implemented global user search integration for Talk chats with role-coded badges and direct chat creation logic
This commit is contained in:
@@ -30,19 +30,19 @@ void openOrCreateDirectChat(
|
||||
return null;
|
||||
}
|
||||
|
||||
void switchToChat(GetRoomResponseObject room) {
|
||||
void switchToChat(String token) {
|
||||
// Pop the previous ChatView first — otherwise it stays in the
|
||||
// back-stack with a now-mismatched currentToken and renders empty
|
||||
// on back-swipe. Stop at popups so an open dialog stays alive.
|
||||
Navigator.of(
|
||||
context,
|
||||
).popUntil((route) => route.isFirst || route is PopupRoute);
|
||||
AppRoutes.openChatByToken(context, room.token);
|
||||
AppRoutes.openChatByToken(context, token);
|
||||
}
|
||||
|
||||
final existing = findExisting();
|
||||
if (existing != null) {
|
||||
switchToChat(existing);
|
||||
switchToChat(existing.token);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,15 +53,11 @@ void openOrCreateDirectChat(
|
||||
'Soll einer erstellt werden?',
|
||||
confirmButton: 'Erstellen',
|
||||
onConfirmAsync: () async {
|
||||
await chatListBloc.createDirectChat(actorId);
|
||||
final created = findExisting();
|
||||
if (created == null) {
|
||||
throw Exception(
|
||||
'Privatchat konnte nach dem Erstellen nicht gefunden werden.',
|
||||
);
|
||||
}
|
||||
if (context.mounted) {
|
||||
switchToChat(created);
|
||||
// The create call returns the new room's token directly, so we open it
|
||||
// without racing the (asynchronously updated) chat-list state.
|
||||
final token = await chatListBloc.createDirectChat(actorId);
|
||||
if (context.mounted && token != null) {
|
||||
switchToChat(token);
|
||||
}
|
||||
},
|
||||
).asDialog(context);
|
||||
|
||||
Reference in New Issue
Block a user