fix: save and restore last used Bible version across sessions
This commit is contained in:
1 parent
73fac73248
commit
cb63254b2f
3 files changed
+6
-21
No files matched your search
+2
-1
@@ -248,7 +248,8 @@ export class App {
|
||||
const biblePassage = bp[3] || '';
|
||||
let bibleVersion: string;
|
||||
if (!versionSpec) {
|
||||
bibleVersion = this.resolveBibleVersion(this.settings.defaultBibleVersion, lang);
|
||||
const lastVersion = localStorage.getItem('ponomar-last-bible-version');
|
||||
bibleVersion = lastVersion || this.resolveBibleVersion(this.settings.defaultBibleVersion, lang);
|
||||
} else if (versionSpec.includes('~')) {
|
||||
// Format: lang~short e.g. "en~kjv" → "en/bible/kjv"
|
||||
const [vl, vs] = versionSpec.split('~');
|
||||
|
||||
@@ -298,5 +298,6 @@ export class BibleView {
|
||||
}
|
||||
|
||||
saveBibleState(this.currentVersion, this.currentBook, this.currentPassage);
|
||||
localStorage.setItem('ponomar-last-bible-version', this.currentVersion);
|
||||
}
|
||||
}
|
||||
+3
-20
@@ -58,12 +58,6 @@ function defaultBibleForLanguage(lang: string): string {
|
||||
return map[lang] || 'kjv';
|
||||
}
|
||||
|
||||
const LANG_LABELS: Record<string, string> = {
|
||||
en: 'English', ru: 'Русский', cu: 'Церковнославянский',
|
||||
el: 'Ἑλληνικά', fr: 'Français', la: 'Latina',
|
||||
zh: '中文', ar: 'العربية',
|
||||
};
|
||||
|
||||
function versionPriority(lang: string, userLang: string): number {
|
||||
if (lang === userLang) return 0;
|
||||
if ((userLang === 'ru' || userLang === 'cu') && (lang === 'ru' || lang === 'cu')) return 1;
|
||||
@@ -339,26 +333,15 @@ export class SettingsView {
|
||||
return pa - pb || a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
// Group by language
|
||||
const groups: Record<string, any[]> = {};
|
||||
for (const v of versions) {
|
||||
if (!groups[v.language]) groups[v.language] = [];
|
||||
groups[v.language].push(v);
|
||||
}
|
||||
|
||||
// Build optgroups in priority order
|
||||
const orderedLangs = [...new Set(versions.map((v: any) => v.language))] as string[];
|
||||
// Build options in priority order
|
||||
const select = document.getElementById('default-bible') as HTMLSelectElement;
|
||||
if (select) {
|
||||
select.innerHTML = orderedLangs.map((lang: string) => {
|
||||
const items = groups[lang];
|
||||
return `<optgroup label="${LANG_LABELS[lang] || lang}">${items.map((v: any) => {
|
||||
select.innerHTML = versions.map((v: any) => {
|
||||
const shortId = v.id.split('/').pop();
|
||||
const size = OfflineManager.getBibleSize(v.id);
|
||||
const comment = size ? ` (${size})` : '';
|
||||
return `<option value="${shortId}" ${this.settings.defaultBibleVersion === shortId ? 'selected' : ''}>${v.name}${comment}</option>`;
|
||||
}).join('')}</optgroup>`;
|
||||
}).join('');
|
||||
}).join('');
|
||||
}
|
||||
} catch {}
|
||||
})();
|
||||
|
||||
Reference in new issue
Block a user