-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checking if there are any active pages to determine whether to upsert
or deactivate the session. Currently done for https only. Http support to follow. Unfortunately, safari is special and would not give the correct focused status for its pages to the service worker as chrome does. Had to work around it with a messaging to the page: 1. sending a request to all active pages to return their focused states 2. setting a timeout of 500ms to wait for responses 3. added a handler on the page and in SW to react to the new events 4. after timeout goes off, check current clientsStatus in SW to trigger session update
- Loading branch information
Showing
5 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
export interface OSWindowClient extends WindowClient { | ||
isSubdomainIframe: boolean; | ||
} | ||
|
||
export interface ClientStatus { | ||
timestamp: number; | ||
sentRequestsCount: number; | ||
receivedResponsesCount: number; | ||
hasAnyActiveSessions: boolean; | ||
} | ||
|
||
export interface PageVisibilityRequest { | ||
timestamp: number; | ||
} | ||
|
||
export interface PageVisibilityResponse extends PageVisibilityRequest { | ||
focused: boolean; | ||
} | ||
|
||
export interface OSServiceWorkerFields { | ||
timerId?: number; | ||
clientsStatus?: ClientStatus; | ||
} |
@itrush Any reason why we used
includeUncontrolled
false
instead oftrue
here?All other usages of
clients.matchAll
useincludeUncontrolled: true
instead.