fix: 修正聊天室雙向即時同步失效問題
- echo.js:還原 disconnect()/connect(),確保 Reverb 重連後重新授權 presence channel - BookingChat.vue:移除 handleNotificationFallback(會覆蓋樂觀更新訊息導致重複) - BookingChat.vue:改用 state_change 事件偵測重連('reconnected' 並非合法 Pusher.js 事件) - BookingChat.vue:移除未使用的 useAuthStore / useCoachAuthStore / currentUserId 依賴 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,16 +24,16 @@ const echo = new Echo({
|
||||
},
|
||||
})
|
||||
|
||||
// 登入後更新 auth header,讓 presence channel 授權帶正確 token
|
||||
// 登入後更新 auth header 並強制重連,確保 Reverb 用新 token 授權 channel
|
||||
export function updateEchoToken() {
|
||||
const token = getAuthToken()
|
||||
const bearer = `Bearer ${token}`
|
||||
echo.options.auth.headers.Authorization = bearer
|
||||
// 同步更新 Pusher 內部 config(避免 Pusher.js 持有舊的 header copy)
|
||||
if (echo.connector?.pusher?.config?.auth?.headers) {
|
||||
echo.connector.pusher.config.auth.headers.Authorization = bearer
|
||||
}
|
||||
// 不 disconnect/connect:避免中斷 BookingChat 已訂閱的 presence channel
|
||||
echo.disconnect()
|
||||
echo.connect()
|
||||
}
|
||||
|
||||
export default echo
|
||||
|
||||
Reference in New Issue
Block a user