Skip to content

Commit 2f16a16

Browse files
authored
Merge pull request #7393 from thornbill/experimental-default
2 parents 762f95c + 86db4bd commit 2f16a16

File tree

8 files changed

+55
-42
lines changed

8 files changed

+55
-42
lines changed

src/RootAppRouter.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ import { STABLE_APP_ROUTES } from 'apps/stable/routes/routes';
1313
import { WIZARD_APP_ROUTES } from 'apps/wizard/routes/routes';
1414
import AppHeader from 'components/AppHeader';
1515
import Backdrop from 'components/Backdrop';
16+
import { SETTING_KEY as LAYOUT_SETTING_KEY } from 'components/layoutManager';
1617
import BangRedirect from 'components/router/BangRedirect';
1718
import { createRouterHistory } from 'components/router/routerHistory';
19+
import { LayoutMode } from 'constants/layoutMode';
20+
import browser from 'scripts/browser';
1821
import appTheme from 'themes/themes';
1922
import { ThemeStorageManager } from 'themes/themeStorageManager';
2023

21-
const layoutMode = localStorage.getItem('layout');
22-
const isExperimentalLayout = layoutMode === 'experimental';
24+
const layoutMode = browser.tv ? LayoutMode.Tv : localStorage.getItem(LAYOUT_SETTING_KEY);
25+
const isExperimentalLayout = !layoutMode || layoutMode === LayoutMode.Experimental;
2326

2427
const router = createHashRouter([
2528
{

src/apps/experimental/features/preferences/components/DisplayPreferences.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import React, { Fragment } from 'react';
1212

1313
import { appHost } from 'components/apphost';
1414
import { AppFeature } from 'constants/appFeature';
15+
import { LayoutMode } from 'constants/layoutMode';
1516
import { useApi } from 'hooks/useApi';
1617
import { useThemes } from 'hooks/useThemes';
1718
import globalize from 'lib/globalize';
@@ -45,11 +46,10 @@ export function DisplayPreferences({ onChange, values }: Readonly<DisplayPrefere
4546
onChange={onChange}
4647
value={values.layout}
4748
>
48-
<MenuItem value='auto'>{globalize.translate('Auto')}</MenuItem>
49-
<MenuItem value='desktop'>{globalize.translate('Desktop')}</MenuItem>
50-
<MenuItem value='mobile'>{globalize.translate('Mobile')}</MenuItem>
51-
<MenuItem value='tv'>{globalize.translate('TV')}</MenuItem>
52-
<MenuItem value='experimental'>{globalize.translate('Experimental')}</MenuItem>
49+
<MenuItem value={LayoutMode.Auto}>{globalize.translate('Auto')}</MenuItem>
50+
<MenuItem value={LayoutMode.Desktop}>{globalize.translate('Desktop')}</MenuItem>
51+
<MenuItem value={LayoutMode.Mobile}>{globalize.translate('Mobile')}</MenuItem>
52+
<MenuItem value={LayoutMode.Tv}>{globalize.translate('TV')}</MenuItem>
5353
</Select>
5454
<FormHelperText component={Stack} id='display-settings-layout-description'>
5555
<span>{globalize.translate('DisplayModeHelp')}</span>

src/components/apphost.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as webSettings from '../scripts/settings/webSettings';
66
import globalize from '../lib/globalize';
77
import profileBuilder from '../scripts/browserDeviceProfile';
88
import { AppFeature } from 'constants/appFeature';
9+
import { LayoutMode } from 'constants/layoutMode';
910

1011
const appName = 'Jellyfin Web';
1112

@@ -181,7 +182,7 @@ function supportsFullscreen() {
181182
}
182183

183184
function getDefaultLayout() {
184-
return 'desktop';
185+
return LayoutMode.Experimental;
185186
}
186187

187188
function supportsHtmlMediaAutoplay() {
@@ -371,7 +372,7 @@ export const appHost = {
371372

372373
return getDefaultLayout();
373374
},
374-
getDeviceProfile: getDeviceProfile,
375+
getDeviceProfile,
375376
init: function () {
376377
if (window.NativeShell) {
377378
return window.NativeShell.AppHost.init();

src/components/displaySettings/displaySettings.template.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ <h2 class="sectionTitle">
172172
<option value="desktop">${Desktop}</option>
173173
<option value="mobile">${Mobile}</option>
174174
<option value="tv">${TV}</option>
175-
<option value="experimental">${Experimental}</option>
176175
</select>
177176
<div class="fieldDescription">${DisplayModeHelp}</div>
178177
<div class="fieldDescription">${LabelPleaseRestart}</div>

src/components/layoutManager.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { LayoutMode } from 'constants/layoutMode';
12

23
import { appHost } from './apphost';
34
import browser from '../scripts/browser';
@@ -14,51 +15,47 @@ function setLayout(instance, layout, selectedLayout) {
1415
}
1516
}
1617

18+
export const SETTING_KEY = 'layout';
19+
1720
class LayoutManager {
1821
tv = false;
1922
mobile = false;
2023
desktop = false;
2124
experimental = false;
2225

23-
setLayout(layout, save) {
24-
if (!layout || layout === 'auto') {
25-
this.autoLayout();
26+
setLayout(layout = '', save = true) {
27+
const layoutValue = (!layout || layout === LayoutMode.Auto) ? '' : layout;
2628

27-
if (save !== false) {
28-
appSettings.set('layout', '');
29-
}
29+
if (!layoutValue) {
30+
this.autoLayout();
3031
} else {
31-
setLayout(this, 'mobile', layout);
32-
setLayout(this, 'tv', layout);
33-
setLayout(this, 'desktop', layout);
34-
35-
this.experimental = layout === 'experimental';
36-
if (this.experimental) {
37-
const legacyLayoutMode = browser.mobile ? 'mobile' : this.defaultLayout || 'desktop';
38-
setLayout(this, legacyLayoutMode, legacyLayoutMode);
39-
}
40-
41-
if (save !== false) {
42-
appSettings.set('layout', layout);
43-
}
32+
setLayout(this, LayoutMode.Mobile, layoutValue);
33+
setLayout(this, LayoutMode.Tv, layoutValue);
34+
setLayout(this, LayoutMode.Desktop, layoutValue);
35+
}
36+
37+
console.debug('[LayoutManager] using layout mode', layoutValue);
38+
this.experimental = layoutValue === LayoutMode.Experimental;
39+
if (this.experimental) {
40+
const legacyLayoutMode = browser.mobile ? LayoutMode.Mobile : LayoutMode.Desktop;
41+
console.debug('[LayoutManager] using legacy layout mode', legacyLayoutMode);
42+
setLayout(this, legacyLayoutMode, legacyLayoutMode);
4443
}
4544

45+
if (save) appSettings.set(SETTING_KEY, layoutValue);
46+
4647
Events.trigger(this, 'modechange');
4748
}
4849

4950
getSavedLayout() {
50-
return appSettings.get('layout');
51+
return appSettings.get(SETTING_KEY);
5152
}
5253

5354
autoLayout() {
54-
// Take a guess at initial layout. The consuming app can override
55-
if (browser.mobile) {
56-
this.setLayout('mobile', false);
57-
} else if (browser.tv || browser.xboxOne || browser.ps4) {
58-
this.setLayout('tv', false);
59-
} else {
60-
this.setLayout(this.defaultLayout || 'tv', false);
61-
}
55+
// Take a guess at initial layout. The consuming app can override.
56+
// NOTE: The fallback to TV mode seems like an outdated choice. TVs should be detected properly or override the
57+
// default layout.
58+
this.setLayout(browser.tv ? LayoutMode.Tv : this.defaultLayout || LayoutMode.Tv, false);
6259
}
6360

6461
init() {

src/components/router/appRouter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import itemHelper from '../itemHelper';
66
import loading from '../loading/loading';
77
import alert from '../alert';
88

9+
import { LayoutMode } from 'constants/layoutMode';
910
import { getItemQuery } from 'hooks/useItem';
1011
import { ServerConnections } from 'lib/jellyfin-apiclient';
1112
import { toApi } from 'utils/jellyfin-apiclient/compat';
@@ -434,7 +435,7 @@ class AppRouter {
434435

435436
const layoutMode = localStorage.getItem('layout');
436437

437-
if (layoutMode === 'experimental' && item.CollectionType == CollectionType.Homevideos) {
438+
if (layoutMode === LayoutMode.Experimental && item.CollectionType == CollectionType.Homevideos) {
438439
url = '#/homevideos?topParentId=' + item.Id;
439440

440441
return url;

src/constants/layoutMode.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** The different layout modes supported by the web app. */
2+
export enum LayoutMode {
3+
/** Automatic layout - the app chose the best layout for the detected device. */
4+
Auto = 'auto',
5+
/** The legacy desktop layout. */
6+
Desktop = 'desktop',
7+
/** The modern React based layout. */
8+
Experimental = 'experimental',
9+
/** The legacy mobile layout. */
10+
Mobile = 'mobile',
11+
/** The TV layout. */
12+
Tv = 'tv'
13+
};

src/strings/en-us.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
"DeleteServerConfirmation": "Are you sure you wish to delete this server?",
233233
"Depressed": "Depressed",
234234
"Descending": "Descending",
235-
"Desktop": "Desktop",
235+
"Desktop": "Desktop (Legacy)",
236236
"DetectingDevices": "Detecting devices",
237237
"DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access. Filtering user device access will prevent them from using new devices until they've been approved here.",
238238
"Digital": "Digital",
@@ -332,7 +332,6 @@
332332
"EveryXHours": "Every {0} hours",
333333
"EveryXMinutes": "Every {0} minutes",
334334
"ExitFullscreen": "Exit full screen",
335-
"Experimental": "Experimental",
336335
"ExtractChapterImagesHelp": "Extracting chapter images will allow clients to display graphical scene selection menus. The process can be slow, resource intensive, and may require several gigabytes of space. It runs when videos are discovered, and also as a nightly scheduled task. The schedule is configurable in the scheduled tasks area. It is not recommended to run this task during peak usage hours.",
337336
"ExtraLarge": "Extra Large",
338337
"Extras": "Extras",
@@ -1217,7 +1216,7 @@
12171216
"MinutesBefore": "minutes before",
12181217
"MixedMoviesShows": "Mixed Movies and Shows",
12191218
"Mixer": "Mixer",
1220-
"Mobile": "Mobile",
1219+
"Mobile": "Mobile (Legacy)",
12211220
"Monday": "Monday",
12221221
"MoreFromValue": "More from {0}",
12231222
"MoreMediaInfo": "Media Info",

0 commit comments

Comments
 (0)