Skip to content

Commit e780ad0

Browse files
committed
store/app: Add personal full_name to UI, updating on RealmUserEvent.
1 parent b7074e9 commit e780ad0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/model/store.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ class PerAccountStore extends ChangeNotifier {
151151
view.maybeAddMessage(event.message);
152152
}
153153
} else if (event is RealmUserEvent) {
154-
debugPrint("server event: realm_user"); // TODO Update our data, and others
154+
debugPrint("server event: realm_user");
155+
if (event.person.user_id == user_id) {
156+
String? new_full_name = event.person.full_name;
157+
if (new_full_name != null) {
158+
full_name = new_full_name;
159+
notifyListeners();
160+
}
161+
}
162+
// TODO Update our other data, and that of other users
155163
} else if (event is UnexpectedEvent) {
156164
debugPrint("server event: ${jsonEncode(event.toJson())}"); // TODO log better
157165
} else {

lib/widgets/app.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ class HomePage extends StatelessWidget {
5757
child: Column(children: [
5858
const Text('🚧 Under construction 🚧'),
5959
const SizedBox(height: 12),
60+
ListenableBuilder(
61+
builder: (BuildContext context, Widget? child) {
62+
return Text.rich(TextSpan(
63+
text: 'You are: ',
64+
children: [bold(store.full_name)]));},
65+
listenable: store,
66+
),
6067
Text.rich(TextSpan(
6168
text: 'Connected to: ',
6269
children: [bold(store.account.realmUrl)])),

0 commit comments

Comments
 (0)