Skip to content

Commit

Permalink
bruig: Add new GC to chat list
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Nov 9, 2023
1 parent 94d18ed commit a107659
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bruig/flutterui/bruig/lib/models/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,14 @@ class ClientModel extends ChangeNotifier {

Map<String, ChatModel> _activeChats = Map<String, ChatModel>();
ChatModel? getExistingChat(String uid) => _activeChats[uid];
ChatModel? getExistingChatByNick(String nick) {
for (var chat in _activeChats.values) {
if (chat.nick == nick) {
return chat;
}
}
return null;
}

Future<ChatModel> _newChat(
String id, String alias, bool isGC, bool startup) async {
Expand Down
4 changes: 4 additions & 0 deletions bruig/flutterui/bruig/lib/screens/new_gc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class NewGCScreenState extends State<NewGCScreen> {
try {
await Golib.createGC(gcName);
await client.readAddressBook();
var newChat = client.getExistingChatByNick(gcName);
if (newChat != null) {
client.startChat(newChat, false);
}
Navigator.pop(context);
} catch (exception) {
showErrorSnackbar(context, 'Unable to create GC: $exception');
Expand Down

0 comments on commit a107659

Please sign in to comment.