Browse Source

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

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

17
pages/chat/index.js

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

Loading…
Cancel
Save