collectHistory function
Implementation
List<List<String>> collectHistory(List<Message> list) {
List<List<String>> result = [];
for (int i = list.length - 1; i >= 0; i -= 2) {
//只添加最近的会话
if (i - 1 > 0) {
result.insert(0, [list[i - 1].text, list[i].text]);
}
if (result.length > 3) {
//放太多轮次也没啥意思
break;
}
}
return result;
}