diff --git a/packages/neon/neon/lib/src/blocs/user_statuses.dart b/packages/neon/neon/lib/src/blocs/user_statuses.dart index d5867aad..03f5e0b7 100644 --- a/packages/neon/neon/lib/src/blocs/user_statuses.dart +++ b/packages/neon/neon/lib/src/blocs/user_statuses.dart @@ -16,7 +16,7 @@ abstract class UserStatusesBlocEvents { } abstract class UserStatusesBlocStates { - BehaviorSubject>> get statuses; + BehaviorSubject>> get statuses; } @internal @@ -39,8 +39,8 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents } @override - BehaviorSubject>> statuses = - BehaviorSubject>>(); + BehaviorSubject>> statuses = + BehaviorSubject>>(); @override Future refresh() async { @@ -58,7 +58,7 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents try { _updateStatus(username, Result.loading()); - UserStatusPublic? data; + UserStatusPublicInterface? data; if (_account.username == username) { var isAway = false; @@ -71,7 +71,7 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents final response = await _account.client.userStatus.heartbeat.heartbeat( status: isAway ? 'away' : 'online', ); - data = response.ocs.data.public; + data = response.ocs.data; } catch (e) { // 204 is returned if the heartbeat failed because the current status is different. Ignore this and fetch the normal status if (e is! DynamiteApiException || e.statusCode != 204) { @@ -97,9 +97,10 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents } } - Map> get _statuses => statuses.valueOrNull ?? >{}; + Map> get _statuses => + statuses.valueOrNull ?? >{}; - void _updateStatus(final String username, final Result result) { + void _updateStatus(final String username, final Result result) { statuses.add({ ..._statuses, username: result, diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index bc56356e..65949cd5 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -85,7 +85,7 @@ class _UserAvatarState extends State { ), ), if (widget.showStatus) ...[ - ResultBuilder( + ResultBuilder( stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]), builder: _userStatusIconBuilder, ), @@ -95,7 +95,7 @@ class _UserAvatarState extends State { }, ); - Widget _userStatusIconBuilder(final BuildContext context, final Result result) { + Widget _userStatusIconBuilder(final BuildContext context, final Result result) { final hasEmoji = result.data?.icon != null; final scaledSize = size / (hasEmoji ? 2 : 2.5); diff --git a/packages/nextcloud/test/user_status_test.dart b/packages/nextcloud/test/user_status_test.dart index 1c1b0d00..7c4b55aa 100644 --- a/packages/nextcloud/test/user_status_test.dart +++ b/packages/nextcloud/test/user_status_test.dart @@ -52,14 +52,14 @@ void main() { test('Set status', () async { final response = await client.userStatus.userStatus.setStatus(statusType: 'online'); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, null); - expect(response.ocs.data.private1.messageId, null); - expect(response.ocs.data.private1.messageIsPredefined, false); - expect(response.ocs.data.public.icon, null); - expect(response.ocs.data.public.clearAt, null); - expect(response.ocs.data.public.status, 'online'); - expect(response.ocs.data.private1.statusIsUserDefined, true); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, null); + expect(response.ocs.data.messageId, null); + expect(response.ocs.data.messageIsPredefined, false); + expect(response.ocs.data.icon, null); + expect(response.ocs.data.clearAt, null); + expect(response.ocs.data.status, 'online'); + expect(response.ocs.data.statusIsUserDefined, true); }); test('Get status', () async { @@ -68,14 +68,14 @@ void main() { await client.userStatus.userStatus.setStatus(statusType: 'online'); final response = await client.userStatus.userStatus.getStatus(); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, null); - expect(response.ocs.data.private1.messageId, null); - expect(response.ocs.data.private1.messageIsPredefined, false); - expect(response.ocs.data.public.icon, null); - expect(response.ocs.data.public.clearAt, null); - expect(response.ocs.data.public.status, 'online'); - expect(response.ocs.data.private1.statusIsUserDefined, true); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, null); + expect(response.ocs.data.messageId, null); + expect(response.ocs.data.messageIsPredefined, false); + expect(response.ocs.data.icon, null); + expect(response.ocs.data.clearAt, null); + expect(response.ocs.data.status, 'online'); + expect(response.ocs.data.statusIsUserDefined, true); }); test('Find all statuses', () async { @@ -111,14 +111,14 @@ void main() { messageId: 'meeting', clearAt: clearAt, ); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, null); - expect(response.ocs.data.private1.messageId, 'meeting'); - expect(response.ocs.data.private1.messageIsPredefined, true); - expect(response.ocs.data.public.icon, null); - expect(response.ocs.data.public.clearAt, clearAt); - expect(response.ocs.data.public.status, 'offline'); - expect(response.ocs.data.private1.statusIsUserDefined, false); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, null); + expect(response.ocs.data.messageId, 'meeting'); + expect(response.ocs.data.messageIsPredefined, true); + expect(response.ocs.data.icon, null); + expect(response.ocs.data.clearAt, clearAt); + expect(response.ocs.data.status, 'offline'); + expect(response.ocs.data.statusIsUserDefined, false); }); test('Set custom message', () async { @@ -128,14 +128,14 @@ void main() { message: 'bla', clearAt: clearAt, ); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, 'bla'); - expect(response.ocs.data.private1.messageId, null); - expect(response.ocs.data.private1.messageIsPredefined, false); - expect(response.ocs.data.public.icon, '😀'); - expect(response.ocs.data.public.clearAt, clearAt); - expect(response.ocs.data.public.status, 'offline'); - expect(response.ocs.data.private1.statusIsUserDefined, false); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, 'bla'); + expect(response.ocs.data.messageId, null); + expect(response.ocs.data.messageIsPredefined, false); + expect(response.ocs.data.icon, '😀'); + expect(response.ocs.data.clearAt, clearAt); + expect(response.ocs.data.status, 'offline'); + expect(response.ocs.data.statusIsUserDefined, false); }); test('Clear message', () async { @@ -148,26 +148,26 @@ void main() { await client.userStatus.userStatus.clearMessage(); final response = await client.userStatus.userStatus.getStatus(); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, null); - expect(response.ocs.data.private1.messageId, null); - expect(response.ocs.data.private1.messageIsPredefined, false); - expect(response.ocs.data.public.icon, null); - expect(response.ocs.data.public.clearAt, null); - expect(response.ocs.data.public.status, 'offline'); - expect(response.ocs.data.private1.statusIsUserDefined, false); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, null); + expect(response.ocs.data.messageId, null); + expect(response.ocs.data.messageIsPredefined, false); + expect(response.ocs.data.icon, null); + expect(response.ocs.data.clearAt, null); + expect(response.ocs.data.status, 'offline'); + expect(response.ocs.data.statusIsUserDefined, false); }); test('Heartbeat', () async { final response = await client.userStatus.heartbeat.heartbeat(status: 'online'); - expect(response.ocs.data.public.userId, 'user1'); - expect(response.ocs.data.public.message, null); - expect(response.ocs.data.private1.messageId, null); - expect(response.ocs.data.private1.messageIsPredefined, false); - expect(response.ocs.data.public.icon, null); - expect(response.ocs.data.public.clearAt, null); - expect(response.ocs.data.public.status, 'online'); - expect(response.ocs.data.private1.statusIsUserDefined, false); + expect(response.ocs.data.userId, 'user1'); + expect(response.ocs.data.message, null); + expect(response.ocs.data.messageId, null); + expect(response.ocs.data.messageIsPredefined, false); + expect(response.ocs.data.icon, null); + expect(response.ocs.data.clearAt, null); + expect(response.ocs.data.status, 'online'); + expect(response.ocs.data.statusIsUserDefined, false); }); }, retry: retryCount,