Skip to content

Commit 5e9f0a3

Browse files
committed
poll [nfc]: Store key on PollOption
This allows us to lookup the key that corresponds to the PollOption without referencing back the map. Signed-off-by: Zixuan James Li <[email protected]>
1 parent c5e7d7f commit 5e9f0a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/api/model/submessage.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class Poll extends ChangeNotifier {
462462

463463
final key = PollEventSubmessage.optionKey(senderId: senderId, idx: idx);
464464
assert(!_options.containsKey(key));
465-
_options[key] = PollOption(text: option);
465+
_options[key] = PollOption(key: key, text: option);
466466
_existingOptionTexts.add(option);
467467
}
468468

@@ -479,8 +479,9 @@ class Poll extends ChangeNotifier {
479479
}
480480

481481
class PollOption {
482-
PollOption({required this.text});
482+
PollOption({required this.key, required this.text});
483483

484+
final PollOptionKey key;
484485
final String text;
485486
final Set<int> voters = {};
486487

0 commit comments

Comments
 (0)