Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Contents Menu Launch Action #653

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions convert/convertContents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cpSync, existsSync, mkdirSync, readFileSync, rmdirSync } from 'fs';
import { cpSync, existsSync, readFileSync, rmSync } from 'fs';
import jsdom from 'jsdom';
import path from 'path';
import { TaskOutput, Task } from './Task';
Expand Down Expand Up @@ -76,7 +76,7 @@ export function convertContents(dataDir: string, configData: ConfigTaskOutput, v
cpSync(contentsDir, destDir, { recursive: true });
} else {
if (existsSync(destDir)) {
rmdirSync(destDir, { recursive: true });
rmSync(destDir, { recursive: true });
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/lib/data/stores/view.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { groupStore } from './store-types';
import { derived, writable, get } from 'svelte/store';
import { derived, writable, get, readable } from 'svelte/store';
import { setDefaultStorage } from './storage';
import { defaultSettings, userSettings } from './setting';
import contents from '../contents';

export const NAVBAR_HEIGHT = '4rem';

/** a local storage flag that keeps track of if the page is at its very first launch */
setDefaultStorage('firstLaunch', true);
export const firstLaunch = writable(localStorage.firstLaunch === 'true');
firstLaunch.subscribe((bool) => (localStorage.firstLaunch = bool));
const nowTime = String(Date.now());
export const launchTime = readable(nowTime);
setDefaultStorage('firstLaunchTime', nowTime);
export const firstLaunchTime = readable(localStorage.firstLaunchTime);
export const isFirstLaunch = derived(
[firstLaunchTime, launchTime],
([$firstLaunchTime, $launchTime]) => $firstLaunchTime === $launchTime
);

/**a group of writable stores to store the top visible verse in a group*/
export const scrolls = groupStore(writable, 'title');
Expand Down
16 changes: 15 additions & 1 deletion src/lib/navigate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ export async function navigateToText(item: {
{ collection: item.collection, book: item.book, chapter: item.chapter, verse: item.verse },
logHistoryItemAdded
);
goto(`${base}/`);
goto(`${base}/text`);
}

export async function navigateToTextReference(reference: string) {
await refs.setReference(reference);
const nowRef: any = get(refs);
goto(`${base}/text`);
addHistory(
{
collection: nowRef.collection,
book: nowRef.book,
chapter: nowRef.chapter
},
logHistoryItemAdded
);
}

export async function navigateToTextChapterInDirection(direction: number) {
Expand Down
7 changes: 2 additions & 5 deletions src/routes/+page.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { initProskomma } from '$lib/data/scripture';

/** @type {import('./$types').PageLoad} */
export async function load({ url, fetch }) {
export async function load({ url }) {
const ref = url.searchParams.get('ref');
const audio = url.searchParams.get('audio');
const proskomma = await initProskomma({ fetch });

return { ref, audio, proskomma };
return { ref, audio };
}
Loading
Loading