fix: settings race condition and URL deep linking
This commit is contained in:
+6
-2
@@ -137,9 +137,13 @@ class App {
|
|||||||
this.navigateTo(page, false); // false = don't add to history
|
this.navigateTo(page, false); // false = don't add to history
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize home page
|
// Initialize home page first (it's needed for channel list)
|
||||||
await this.pages.home.init();
|
await this.pages.home.init();
|
||||||
this.navigateTo('home', true); // true = replace history (don't add)
|
|
||||||
|
// Navigate to the page from URL hash, or default to home
|
||||||
|
const hash = window.location.hash.slice(1); // Remove #
|
||||||
|
const initialPage = hash && this.pages[hash] ? hash : 'home';
|
||||||
|
this.navigateTo(initialPage, true); // true = replace history (don't add)
|
||||||
|
|
||||||
console.log('NodeCast TV initialized');
|
console.log('NodeCast TV initialized');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class SettingsPage {
|
|||||||
this.updateEpgLastRefreshed();
|
this.updateEpgLastRefreshed();
|
||||||
}
|
}
|
||||||
|
|
||||||
initTranscodingSettings() {
|
async initTranscodingSettings() {
|
||||||
// Encoder settings
|
// Encoder settings
|
||||||
const hwEncoderSelect = document.getElementById('setting-hw-encoder');
|
const hwEncoderSelect = document.getElementById('setting-hw-encoder');
|
||||||
const maxResolutionSelect = document.getElementById('setting-max-resolution');
|
const maxResolutionSelect = document.getElementById('setting-max-resolution');
|
||||||
@@ -113,9 +113,14 @@ class SettingsPage {
|
|||||||
const userAgentCustomInput = document.getElementById('setting-user-agent-custom-tc');
|
const userAgentCustomInput = document.getElementById('setting-user-agent-custom-tc');
|
||||||
const customUaContainer = document.getElementById('custom-user-agent-container-tc');
|
const customUaContainer = document.getElementById('custom-user-agent-container-tc');
|
||||||
|
|
||||||
// Load current settings
|
// Fetch settings directly from API to avoid race condition with VideoPlayer
|
||||||
if (this.app.player?.settings) {
|
let s;
|
||||||
const s = this.app.player.settings;
|
try {
|
||||||
|
s = await API.settings.get();
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[Settings] Failed to load settings from API, using player defaults:', err);
|
||||||
|
s = this.app.player?.settings || {};
|
||||||
|
}
|
||||||
|
|
||||||
if (hwEncoderSelect) hwEncoderSelect.value = s.hwEncoder || 'auto';
|
if (hwEncoderSelect) hwEncoderSelect.value = s.hwEncoder || 'auto';
|
||||||
if (maxResolutionSelect) maxResolutionSelect.value = s.maxResolution || '1080p';
|
if (maxResolutionSelect) maxResolutionSelect.value = s.maxResolution || '1080p';
|
||||||
@@ -131,7 +136,6 @@ class SettingsPage {
|
|||||||
if (customUaContainer) {
|
if (customUaContainer) {
|
||||||
customUaContainer.style.display = userAgentSelect?.value === 'custom' ? 'flex' : 'none';
|
customUaContainer.style.display = userAgentSelect?.value === 'custom' ? 'flex' : 'none';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Event listeners for encoder settings
|
// Event listeners for encoder settings
|
||||||
hwEncoderSelect?.addEventListener('change', () => {
|
hwEncoderSelect?.addEventListener('change', () => {
|
||||||
@@ -152,7 +156,7 @@ class SettingsPage {
|
|||||||
// Audio Mix Preset
|
// Audio Mix Preset
|
||||||
const audioMixSelect = document.getElementById('setting-audio-mix');
|
const audioMixSelect = document.getElementById('setting-audio-mix');
|
||||||
if (audioMixSelect) {
|
if (audioMixSelect) {
|
||||||
audioMixSelect.value = this.app.player?.settings?.audioMixPreset || 'auto';
|
audioMixSelect.value = s.audioMixPreset || 'auto';
|
||||||
audioMixSelect.addEventListener('change', () => {
|
audioMixSelect.addEventListener('change', () => {
|
||||||
this.app.player.settings.audioMixPreset = audioMixSelect.value;
|
this.app.player.settings.audioMixPreset = audioMixSelect.value;
|
||||||
this.app.player.saveSettings();
|
this.app.player.saveSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user