Skip to content

Commit b304944

Browse files
committed
fixing the navigation to preview
1 parent 90f6a4d commit b304944

File tree

4 files changed

+27
-38
lines changed

4 files changed

+27
-38
lines changed

src/browser/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ import ReactDOM from 'react-dom'
2222

2323
import AppInit, { setupSentry } from './AppInit'
2424
import './init'
25+
import { navigateToPreview } from './modules/Stream/StartPreviewFrame'
2526

2627
setupSentry()
2728
;(async () => {
2829
const doesPreferQuery = localStorage.getItem('prefersOldBrowser') === 'false'
29-
30-
const response = await fetch('/preview/manifest.json')
31-
if (response.status === 200) {
32-
if (doesPreferQuery) {
33-
window.location.pathname = '/preview/'
30+
try {
31+
const response = await fetch('./preview/manifest.json')
32+
if (response.status === 200) {
33+
if (doesPreferQuery) {
34+
navigateToPreview()
35+
} else {
36+
localStorage.setItem('previewAvailable', 'true')
37+
}
3438
} else {
35-
localStorage.setItem('previewAvailable', 'true')
39+
localStorage.setItem('previewAvailable', 'false')
3640
}
37-
} else {
41+
} catch (e) {
3842
localStorage.setItem('previewAvailable', 'false')
3943
}
4044

src/browser/modules/Stream/PlayFrame.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ import { getEdition, isEnterprise } from 'shared/modules/dbMeta/dbMetaDuck'
4848
import { DARK_THEME } from 'shared/modules/settings/settingsDuck'
4949
import { LAST_GUIDE_SLIDE } from 'shared/modules/udc/udcDuck'
5050
import { PreviewFrame } from './StartPreviewFrame'
51-
import {
52-
experimentalFeaturePreviewName,
53-
showFeature
54-
} from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck'
5551

5652
const AuraPromotion = () => {
5753
const theme = useContext(ThemeContext)
@@ -93,15 +89,13 @@ type PlayFrameProps = {
9389
showPromotion: boolean
9490
isFullscreen: boolean
9591
isCollapsed: boolean
96-
isAdvertiseFlagOn: boolean
9792
}
9893
export function PlayFrame({
9994
stack,
10095
bus,
10196
showPromotion,
10297
isFullscreen,
103-
isCollapsed,
104-
isAdvertiseFlagOn
98+
isCollapsed
10599
}: PlayFrameProps): JSX.Element {
106100
const [stackIndex, setStackIndex] = useState(0)
107101
const [atSlideStart, setAtSlideStart] = useState<boolean | null>(null)
@@ -130,8 +124,7 @@ export function PlayFrame({
130124
bus,
131125
onSlide,
132126
initialPlay,
133-
showPromotion,
134-
isAdvertiseFlagOn
127+
showPromotion
135128
)
136129
if (stillMounted) {
137130
setInitialPlay(false)
@@ -214,8 +207,7 @@ function generateContent(
214207
bus: Bus,
215208
onSlide: any,
216209
shouldUseSlidePointer: boolean,
217-
showPromotion = false,
218-
isAdvertiseFlagOn: boolean
210+
showPromotion = false
219211
): Content | Promise<Content> {
220212
// Not found
221213
if (stackFrame.response && stackFrame.response.status === 404) {
@@ -298,17 +290,16 @@ function generateContent(
298290
if (isPlayChapter(guideName)) {
299291
const isPreviewAvailable =
300292
localStorage.getItem('previewAvailable') === 'true'
301-
const showAdvertiseTile = isAdvertiseFlagOn && isPreviewAvailable
302293
const { content, title, subtitle, slides = null } = chapters[guideName]
303294

304295
const isPlayStart = stackFrame.cmd.trim() === ':play start'
305296
const updatedContent =
306297
isPlayStart && showPromotion ? (
307298
<>
308-
{showAdvertiseTile ? <PreviewFrame /> : content}
299+
{isPreviewAvailable ? <PreviewFrame /> : content}
309300
<AuraPromotion />
310301
</>
311-
) : showAdvertiseTile ? (
302+
) : isPreviewAvailable ? (
312303
<PreviewFrame />
313304
) : (
314305
content
@@ -392,8 +383,7 @@ const mapStateToProps = (state: GlobalState) => ({
392383
(getEdition(state) !== null &&
393384
!isEnterprise(state) &&
394385
!isConnectedAuraHost(state)) ||
395-
inDesktop(state),
396-
isAdvertiseFlagOn: showFeature(state, experimentalFeaturePreviewName)
386+
inDesktop(state)
397387
})
398388

399389
export default connect(mapStateToProps)(withBus(PlayFrame))

src/browser/modules/Stream/StartPreviewFrame.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
*/
2020
import React from 'react'
2121

22+
export const navigateToPreview = (): void => {
23+
const path = window.location.pathname
24+
if (!path.endsWith('/preview/')) {
25+
window.location.pathname = `${path}${path.endsWith('/') ? '' : '/'}preview/`
26+
}
27+
}
28+
2229
export const PreviewFrame = () => {
2330
return (
2431
<>
@@ -27,15 +34,10 @@ export const PreviewFrame = () => {
2734
<img src="./assets/images/clusters.svg" className="img-advertise" />
2835
<h3>Discover the new Browser experience! ✨</h3>
2936
<p>
30-
Take a tour of our redesigned interface, built for faster navigation
31-
and ease of use.
37+
Switch to our redesigned interface, built for faster navigation and
38+
ease of use.
3239
</p>
33-
<button
34-
onClick={() => {
35-
window.location.pathname = '/preview/'
36-
}}
37-
className="btn btn-advertise"
38-
>
40+
<button onClick={navigateToPreview} className="btn btn-advertise">
3941
Switch to new experience
4042
</button>
4143
</div>

src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@ export const showFeature = (state: any, name: any) =>
99
!!(state[NAME][name] || {}).on
1010

1111
export const experimentalFeatureSelfName = 'showSelf'
12-
export const experimentalFeaturePreviewName = 'advertisePreview'
1312

1413
export const initialState = {
1514
[experimentalFeatureSelfName]: {
1615
name: experimentalFeatureSelfName,
1716
on: true,
1817
displayName: 'Show experimental features',
1918
tooltip: 'Show feature section in settings drawer'
20-
},
21-
[experimentalFeaturePreviewName]: {
22-
name: experimentalFeaturePreviewName,
23-
on: false,
24-
displayName: 'Advertise preview of new browser',
25-
tooltip: 'Enable the advertisement tile of the new browser'
2619
}
2720
}
2821

0 commit comments

Comments
 (0)