Skip to content

Commit ce5882b

Browse files
Merge pull request #2004 from daveajrussell/localhost-preview-rollout
Adds a localhost preview-as-default rollout service. This will opt in all users on localhost by default, excluding those who have previously opted in to the preview, and then reverted to the old Browser.
2 parents 41d28bf + 55e54c0 commit ce5882b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/browser/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ import ReactDOM from 'react-dom'
2323
import AppInit, { setupSentry } from './AppInit'
2424
import './init'
2525
import { navigateToPreview } from './modules/Stream/StartPreviewFrame'
26+
import { optedInByLocalhost } from 'browser-services/preview-optin-service'
2627

2728
setupSentry()
29+
2830
;(async () => {
29-
const doesPreferQuery = localStorage.getItem('prefersOldBrowser') === 'false'
31+
const optedInToPreview = optedInByLocalhost()
3032
try {
3133
const response = await fetch('./preview/manifest.json')
3234
if (response.status === 200) {
33-
if (doesPreferQuery) {
35+
if (optedInToPreview) {
3436
navigateToPreview()
3537
} else {
3638
localStorage.setItem('previewAvailable', 'true')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const notOptedOutOfPreview = (): boolean => {
2+
const prefersOldBrowser = localStorage.getItem('prefersOldBrowser')
3+
const doesPreferQuery = prefersOldBrowser === 'false'
4+
5+
return doesPreferQuery || prefersOldBrowser === null
6+
}
7+
8+
export const optedInByLocalhost = (): boolean => {
9+
return notOptedOutOfPreview() && window.location.hostname === 'localhost'
10+
}

0 commit comments

Comments
 (0)