change: Implement contact list instead of status
This commit is contained in:
parent
cb0f2b0631
commit
237240407f
10 changed files with 216 additions and 288 deletions
|
|
@ -1,7 +1,34 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
|
||||
extension ClientPresenceExtension on Client {
|
||||
List<Presence> get statuses => presences.values
|
||||
.where((p) => p.presence.statusMsg?.isNotEmpty ?? false)
|
||||
.toList();
|
||||
List<Presence> get contactList {
|
||||
final directChatsMxid = rooms
|
||||
.where((r) => r.isDirectChat)
|
||||
.map((r) => r.directChatMatrixID)
|
||||
.toSet();
|
||||
final contactList = directChatsMxid
|
||||
.map(
|
||||
(mxid) =>
|
||||
presences[mxid] ??
|
||||
Presence.fromJson(
|
||||
{
|
||||
'sender': mxid,
|
||||
'type': 'm.presence',
|
||||
'content': {'presence': 'online'},
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
contactList.addAll(
|
||||
presences.values
|
||||
.where((p) =>
|
||||
!directChatsMxid.contains(p.senderId) &&
|
||||
(p.presence?.statusMsg?.isNotEmpty ?? false))
|
||||
.toList(),
|
||||
);
|
||||
contactList.sort((a, b) => (a.presence.lastActiveAgo?.toDouble() ??
|
||||
double.infinity)
|
||||
.compareTo((b.presence.lastActiveAgo?.toDouble() ?? double.infinity)));
|
||||
return contactList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue