feat: Implement new status feature
This commit is contained in:
parent
0f056a4b86
commit
c5d84c22ca
10 changed files with 329 additions and 245 deletions
|
|
@ -1,10 +1,7 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
|
||||
extension ClientPresenceExtension on Client {
|
||||
static final Map<String, Profile> presencesCache = {};
|
||||
|
||||
Future<Profile> requestProfileCached(String senderId) async {
|
||||
presencesCache[senderId] ??= await getProfileFromUserId(senderId);
|
||||
return presencesCache[senderId];
|
||||
}
|
||||
List<Presence> get statuses => presences.values
|
||||
.where((p) => p.presence.statusMsg?.isNotEmpty ?? false)
|
||||
.toList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
import 'date_time_extension.dart';
|
||||
|
||||
extension PresenceExtension on Presence {
|
||||
bool get isUserStatus => presence?.statusMsg?.isNotEmpty ?? false;
|
||||
|
||||
String getLocalizedStatusMessage(BuildContext context) {
|
||||
if (presence.statusMsg?.isNotEmpty ?? false) {
|
||||
return presence.statusMsg;
|
||||
|
|
|
|||
21
lib/utils/user_status.dart
Normal file
21
lib/utils/user_status.dart
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class UserStatus {
|
||||
String statusMsg;
|
||||
String userId;
|
||||
int receivedAt;
|
||||
|
||||
UserStatus();
|
||||
|
||||
UserStatus.fromJson(Map<String, dynamic> json) {
|
||||
statusMsg = json['status_msg'];
|
||||
userId = json['user_id'];
|
||||
receivedAt = json['received_at'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['status_msg'] = statusMsg;
|
||||
data['user_id'] = userId;
|
||||
data['received_at'] = receivedAt;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue