Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

スマホで長時間バックグラウンドにしていた際に新しいメッセージが取得できない問題を修正 #4118

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/lib/websocket/AutoReconnectWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@

let count = 0
while (!this.isOpen) {
count++

const delay = this._getDelay(count)
count++

Check warning on line 149 in src/lib/websocket/AutoReconnectWebSocket.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/websocket/AutoReconnectWebSocket.ts#L149

Added line #L149 was not covered by tests
await wait(delay)

if (this.isOpen) break
Expand Down
6 changes: 6 additions & 0 deletions src/lib/websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
}
}

document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
ws.connect()
}
})

Check warning on line 45 in src/lib/websocket/index.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/websocket/index.ts#L42-L45

Added lines #L42 - L45 were not covered by tests

export const wsListener = createWebSocketListener(ws)

export const setupWebSocket = async () => {
Expand Down