fix: 修正即時聊天室 presence channel 間歇性失效
三個根本原因: 1. updateEchoToken() 呼叫 disconnect/connect 會中斷已訂閱的 presence channel,改為只更新 auth header(不重連)。 同時將 setAuth() 的呼叫順序改為先 updateEchoToken() 再 startRealtime(),確保訂閱時使用最新 token。 2. BookingPresenceChannel::join() 未對 schedule null 做防守, 載入後若 schedule 不存在會 500,導致 auth 靜默失敗。 3. WebSocket 重連後 presence channel 不會自動恢復, 在 BookingChat 加入 reconnected 事件處理,重連後重訂閱。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,8 +29,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
localStorage.setItem('user', JSON.stringify(userData))
|
||||
const ns = useNotificationStore()
|
||||
ns.startPolling()
|
||||
ns.startRealtime(userData.id)
|
||||
updateEchoToken()
|
||||
ns.startRealtime(userData.id)
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
|
||||
@@ -29,8 +29,8 @@ export const useCoachAuthStore = defineStore('coachAuth', () => {
|
||||
localStorage.setItem('coach_user', JSON.stringify(userData))
|
||||
const ns = useNotificationStore()
|
||||
ns.startPolling()
|
||||
ns.startRealtime(userData.id)
|
||||
updateEchoToken()
|
||||
ns.startRealtime(userData.id)
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
|
||||
Reference in New Issue
Block a user