Browse Source

修复从聊天详情页返回时消息列表更新不及时的问题

pull/1/head
徐飞洋 3 months ago
parent
commit
24b1674ae7
  1. 19
      pages/chat/index.js

19
pages/chat/index.js

@ -62,9 +62,22 @@ Page({
},
onShow: function () {
// 只有已登录用户才启动定时器
if (!this.data.timer && this.isUserLoggedIn()) {
this.startTimer();
// 只有已登录用户才执行操作
if (this.isUserLoggedIn()) {
// 从聊天详情页返回时,强制刷新列表,绕过节流限制
// 保存当前时间戳,用于强制刷新
const forcedLoadTime = Date.now();
this.setData({
lastLoadTime: forcedLoadTime - 3000, // 设置为3秒前,确保能绕过2秒的节流限制
}, () => {
// 重新加载聊天列表,实现从聊天详情页返回时立即更新
this.loadChatList();
});
// 启动定时器
if (!this.data.timer) {
this.startTimer();
}
}
},

Loading…
Cancel
Save