diff --git a/lib/apps/chat/list.dart b/lib/apps/chat/list.dart index 60358f1..57d0764 100644 --- a/lib/apps/chat/list.dart +++ b/lib/apps/chat/list.dart @@ -31,7 +31,6 @@ class _ChatListState extends State { this._friends.clear(); final res = await httpPost('chat-friend-list', [false]); if (res.isOk) { - print(res.params); res.params.forEach((params) { this._friends.add(Friend.fromList(params)); }); diff --git a/lib/apps/group/list.dart b/lib/apps/group/list.dart index b752c96..df57b15 100644 --- a/lib/apps/group/list.dart +++ b/lib/apps/group/list.dart @@ -5,6 +5,7 @@ import 'package:esse/utils/adaptive.dart'; import 'package:esse/l10n/localizations.dart'; import 'package:esse/provider.dart'; import 'package:esse/session.dart'; +import 'package:esse/rpc.dart'; import 'package:esse/apps/group/detail.dart'; import 'package:esse/apps/group/models.dart'; @@ -17,22 +18,39 @@ class GroupChatList extends StatefulWidget { } class _GroupChatListState extends State { + List _groups = []; + + @override + void initState() { + super.initState(); + _loadGroups(); + } + + _loadGroups() async { + this._groups.clear(); + final res = await httpPost('group-list', []); + if (res.isOk) { + res.params.forEach((params) { + this._groups.add(GroupChat.fromList(params)); + }); + setState(() {}); + } else { + print(res.error); + } + } + @override Widget build(BuildContext context) { - //final color = Theme.of(context).colorScheme; final lang = AppLocalizations.of(context); final isDesktop = isDisplayDesktop(context); - //final provider = context.watch(); - final orderKeys = []; //provider.orderKeys; - final groups = []; //provider.groups; return Scaffold( appBar: AppBar(title: Text(lang.groupChat)), body: Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: ListView.builder( - itemCount: orderKeys.length, - itemBuilder: (BuildContext ctx, int index) => ListChat(group: groups[orderKeys[index]]!), + itemCount: _groups.length, + itemBuilder: (BuildContext ctx, int index) => ListChat(group: _groups[index]), ) ), ); @@ -53,7 +71,6 @@ class ListChat extends StatelessWidget { behavior: HitTestBehavior.opaque, onTap: () { context.read().updateActivedSession(0, SessionType.Group, group.id); - //context.read().updateActivedGroup(group.id); final widget = GroupChatDetail(id: group.id); if (!isDesktop) { Navigator.push(context, MaterialPageRoute(builder: (_) => widget)); diff --git a/lib/widgets/chat_message.dart b/lib/widgets/chat_message.dart index 5fa1ece..2e9e8c9 100644 --- a/lib/widgets/chat_message.dart +++ b/lib/widgets/chat_message.dart @@ -332,6 +332,7 @@ class ChatMessage extends StatelessWidget { color: color.onPrimary.withOpacity(0.5), fontSize: 10.0)), const SizedBox(width: 4.0), + if (message.isMe) Icon( message.isDelivery == null ? Icons.hourglass_top : (message.isDelivery! ? Icons.done : Icons.error), diff --git a/src/rpc.rs b/src/rpc.rs index 5a7de63..92ffed4 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -88,7 +88,7 @@ pub(crate) fn session_last( #[inline] pub(crate) fn notice_menu(mgid: GroupId, t: &SessionType) -> RpcParam { - rpc_response(0, "notice_menu", json!([t.to_int()]), mgid) + rpc_response(0, "notice-menu", json!([t.to_int()]), mgid) } #[inline]