iOS quick response (w.i.p)

This commit is contained in:
2024-12-21 21:06:14 +08:00
parent e458943f56
commit be98fe133d
11 changed files with 154 additions and 35 deletions

View File

@ -125,10 +125,8 @@ class ChatChannelProvider extends ChangeNotifier {
final channelBox = await Hive.openBox<SnChatMessage>(
'${ChatMessageController.kChatMessageBoxPrefix}${channel.id}',
);
final lastMessage = channelBox.isNotEmpty
? channelBox.values
.reduce((a, b) => a.createdAt.isAfter(b.createdAt) ? a : b)
: null;
final lastMessage =
channelBox.isNotEmpty ? channelBox.values.reduce((a, b) => a.createdAt.isAfter(b.createdAt) ? a : b) : null;
if (lastMessage != null) result.add(lastMessage);
channelBox.close();
}
@ -142,3 +140,19 @@ class ChatChannelProvider extends ChangeNotifier {
super.dispose();
}
}
Future<void> chatReplyMessage(channelId, eventId, String message) async {
print('Chat reply message called with $channelId $eventId $message');
try {
final snc = await SnNetworkProvider.createOffContextClient();
await snc.post('/cgi/im/quick/$channelId/reply/$eventId', data: {
'type': 'messages.new',
'body': {
'text': message,
'algorithm': 'plain',
},
});
} catch (err) {
print('Failed to send chat reply message: $err');
}
}