Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bruig: Add new GC to chat list #376

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not safe because you can have a gc and a user with the same nick/alias

you need to specify a isGC bool or modify Golib.createGC to return the uid of the gc and then use that uid to getExistingChat

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
Loading