getTopicMessages method
Implementation
Future<List<Message>> getTopicMessages(
String? topic, String? currentUid, int? page, int? size) async {
// debugPrint('1: ' + topic! + ' currentUid:' + currentUid!);
// FIXME: 暂不支持web
if (BytedeskUtils.isWeb) {
return [];
}
// debugPrint('2');
//
List<Map> maps = await database!.query(tableMessage!,
columns: [
columnUid!,
columnType!,
columnContent!,
columnStatus!,
columnCreatedAt!,
columnClient!,
columnExtra!,
//
columnThreadTopic!,
//
columnUserUid!,
columnUserNickname!,
columnUserAvatar!,
//
columnCurrentUid!,
],
where: '$columnThreadTopic = ? and $columnCurrentUid = ?',
whereArgs: [topic, currentUid],
orderBy: '$columnCreatedAt DESC',
limit: size,
offset: page! * size!);
//
// debugPrint('3');
// BytedeskUtils.printLog(maps.length);
//
return List.generate(maps.length, (i) {
// debugPrint('4');
return Message(
uid: maps[i][columnUid],
type: maps[i][columnType],
content: maps[i][columnContent],
status: maps[i][columnStatus],
createdAt: maps[i][columnCreatedAt],
client: maps[i][columnClient],
extra: maps[i][columnExtra],
//
threadTopic: maps[i][columnThreadTopic],
//
user: UserProtobuf(
uid: maps[i][columnUserUid],
nickname: maps[i][columnUserNickname],
avatar: maps[i][columnUserAvatar],
),
);
});
}