- {partitionLine( gurmukhi, !vishraamCharacters ).map(
+ {partitionLine( gurmukhi, !pauses.characters ).map(
( line, lineIndex ) => (
{line.map( ( { word, type }, i ) => (
@@ -157,7 +95,7 @@ const Line = ( {
|| syllabicWeights
|| inlineColumnGuides,
} )}
- style={relativeGurmukhiFontSize ? { fontSize: `${relativeGurmukhiFontSize}em` } : {}}
+ style={{ fontSize: `${fontSizes.relativeGurmukhi}em` }}
>
{word}
@@ -173,8 +111,8 @@ const Line = ( {
.map( ( [ languageId, transliterate ] ) => (
{transliterate( word )}
@@ -201,10 +139,10 @@ const Line = ( {
>
{translation}
@@ -222,14 +160,14 @@ const Line = ( {
>
{classifyWords(
transliterate( gurmukhi ),
- !vishraamCharacters
+ !pauses.characters
).map( ( { word, type }, i ) => (
{
}
}, [ history, lines, previousLines, navigate, pathname ] )
- const settings = useContext( SettingsContext )
- const { local: { theme: { simpleGraphics: simple } } } = settings
+ const [ { accessibility: { reducedMotion: simple } } ] = useLocalSettings()
return (
diff --git a/apps/frontend/src/app/presenter/controller/search/-components/Result.tsx b/apps/frontend/src/app/presenter/controller/search/-components/Result.tsx
index bbbdb2ff..b888c6db 100644
--- a/apps/frontend/src/app/presenter/controller/search/-components/Result.tsx
+++ b/apps/frontend/src/app/presenter/controller/search/-components/Result.tsx
@@ -2,11 +2,11 @@ import { ListItem } from '@mui/material'
import classNames from 'classnames'
import { forwardRef, useContext } from 'react'
-import { RecommendedSourcesContext, SettingsContext, WritersContext } from '~/helpers/contexts'
+import { RecommendedSourcesContext, WritersContext } from '~/helpers/contexts'
import { LANGUAGE_NAMES, SOURCE_ABBREVIATIONS, TRANSLITERATORS } from '~/helpers/data'
import { customiseLine, getTranslation } from '~/helpers/line'
import { setContent } from '~/services/content'
-import controller from '~/services/controller'
+import { useLocalSettings } from '~/services/settings'
type ResultProps = {
gurmukhi: string,
@@ -33,31 +33,31 @@ const Result = forwardRef( ( {
sourcePage,
translations,
}: ResultProps, ref ) => {
- const { local: {
+ const [ {
sources,
- search: {
- showResultCitations,
- resultTransliterationLanguage,
- resultTranslationLanguage,
+ results: {
+ citations,
+ transliterationLanguage,
+ translationLanguage,
lineEnding,
},
- } = {} } = useContext( SettingsContext )
+ } ] = useLocalSettings()
const writers = useContext( WritersContext )
const recommendedSources = useContext( RecommendedSourcesContext )
- const transliteration = resultTransliterationLanguage && customiseLine(
- TRANSLITERATORS[ resultTransliterationLanguage ]( gurmukhi ),
+ const transliteration = transliterationLanguage && customiseLine(
+ TRANSLITERATORS[ transliterationLanguage ]( gurmukhi ),
{ lineEnding, typeId },
)
- const translation = resultTranslationLanguage && translations && customiseLine(
+ const translation = translationLanguage && translations && customiseLine(
getTranslation( {
line: { translations },
shabad: { sourceId },
recommendedSources,
sources,
- languageId: resultTranslationLanguage,
+ languageId: translationLanguage,
} ),
{ lineEnding, typeId },
)
@@ -71,7 +71,7 @@ const Result = forwardRef( ( {
const onClick = () => setContent( { id: shabadId, lineId, type: 'shabad' } )
// Helper render functions for citation
- const showCitation = showResultCitations && shabad?.section
+ const showCitation = citations && shabad?.section
const getEnglish = ( { nameEnglish } ) => nameEnglish
const getWriterName = () => getEnglish( writers[ shabad.writerId ] )
const getPageName = () => recommendedSources[ shabad.sourceId ].pageNameEnglish
@@ -87,13 +87,13 @@ const Result = forwardRef( ( {
{translation && (
-
+
{translation}
)}
{transliteration && (
-
+
{translitBeforeMatch &&
{translitBeforeMatch}}
{translitMatch &&
{translitMatch}}
{translitAfterMatch &&
{translitAfterMatch}}
diff --git a/apps/frontend/src/app/presenter/controller/search/index.tsx b/apps/frontend/src/app/presenter/controller/search/index.tsx
index 1d35747e..a1a46b1c 100644
--- a/apps/frontend/src/app/presenter/controller/search/index.tsx
+++ b/apps/frontend/src/app/presenter/controller/search/index.tsx
@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { IconButton, Input, InputAdornment, List } from '@mui/material'
import { createFileRoute, useNavigate } from '@tanstack/react-router'
import classNames from 'classnames'
-import { useCallback, useContext, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { withNavigationHotkeys } from '~/components/NavigationHotkeys'
import {
@@ -14,8 +14,8 @@ import {
SEARCH_CHARS,
SEARCH_TYPES,
} from '~/helpers/consts'
-import { SettingsContext } from '~/helpers/contexts'
import { search, useSearchResults } from '~/services/search'
+import { useLocalSettings } from '~/services/settings'
import Result from './-components/Result'
import getHighlighter from './-match-highlighter'
@@ -44,13 +44,13 @@ type SearchProps = {
}
const Search = ( { updateFocus, register, focused }: SearchProps ) => {
- const { local: {
- search: {
- showResultCitations,
- resultTransliterationLanguage,
- resultTranslationLanguage,
+ const [ {
+ results: {
+ citations,
+ transliterationLanguage,
+ translationLanguage,
},
- } = {} } = useContext( SettingsContext )
+ } ] = useLocalSettings()
// Set the initial search query from URL
const navigate = useNavigate()
@@ -86,9 +86,9 @@ const Search = ( { updateFocus, register, focused }: SearchProps ) => {
query: searchValue,
type: searchType,
options: {
- translations: !!resultTranslationLanguage,
- transliterations: !!resultTransliterationLanguage,
- citations: !!showResultCitations,
+ translations: !!translationLanguage,
+ transliterations: !!transliterationLanguage,
+ citations: !!citations,
},
} )
} else clearResults()
@@ -106,9 +106,9 @@ const Search = ( { updateFocus, register, focused }: SearchProps ) => {
} )
}, [
navigate,
- resultTranslationLanguage,
- resultTransliterationLanguage,
- showResultCitations,
+ translationLanguage,
+ transliterationLanguage,
+ citations,
] )
const filterInputKeys = ( event ) => {
@@ -129,9 +129,9 @@ const Search = ( { updateFocus, register, focused }: SearchProps ) => {
}, [
onChange,
anchor,
- resultTransliterationLanguage,
- resultTranslationLanguage,
- showResultCitations,
+ transliterationLanguage,
+ translationLanguage,
+ citations,
] )
useEffect( () => { highlightSearch() }, [] )
diff --git a/apps/frontend/src/app/presenter/route.lazy.tsx b/apps/frontend/src/app/presenter/route.lazy.tsx
index daa32bf3..81810ca9 100644
--- a/apps/frontend/src/app/presenter/route.lazy.tsx
+++ b/apps/frontend/src/app/presenter/route.lazy.tsx
@@ -6,7 +6,7 @@ import { CssBaseline } from '@mui/material'
import IconButton from '@mui/material/IconButton'
import { createLazyFileRoute, Outlet, useLocation } from '@tanstack/react-router'
import classNames from 'classnames'
-import { lazy, Suspense, useContext, useRef, useState } from 'react'
+import { lazy, Suspense, useRef, useState } from 'react'
import { EventsType, useIdleTimer } from 'react-idle-timer'
import CopyHotkeys from '~/components/CopyHotkeys'
@@ -16,12 +16,12 @@ import Loader from '~/components/Loader'
import NavigatorHotKeys from '~/components/NavigatorHotkeys'
import ThemeLoader from '~/components/ThemeLoader'
import { isDesktop } from '~/helpers/consts'
-import { SettingsContext } from '~/helpers/contexts'
import { toggleFullscreen } from '~/helpers/electron-utils'
import { GLOBAL_SHORTCUTS } from '~/helpers/keyMap'
import { CLIENT_OPTIONS } from '~/helpers/options'
import { useNavigateUtils } from '~/hooks/navigate'
import { clearLine, useContent } from '~/services/content'
+import { useLocalSettings } from '~/services/settings'
import StatusToast from './-components/StatusToast'
import { ControllerLocationHistoryProvider } from './-controller-location-history'
@@ -62,23 +62,22 @@ const Presenter = () => {
const { lines } = useContent()
- const { local: localSettings } = useContext( SettingsContext )
- const {
- theme: { themeName },
- layout: { controllerZoom: zoom },
+ const [ {
+ themeName,
+ controllerZoom,
hotkeys,
- } = localSettings
+ } ] = useLocalSettings()
const toggleController = () => void navigate( { to: isControllerOpen ? '/' : '/presenter/controller' } )
- const { controllerZoom } = CLIENT_OPTIONS
+ // const { controllerZoom } = CLIENT_OPTIONS
// const setZoom = ( controllerZoom: number ) => controller.setSettings( {
// layout: { controllerZoom },
// } )
const setZoom = () => {}
- const zoomInController = () => setZoom( Math.min( controllerZoom.max, zoom + 0.1 ) )
- const zoomOutController = () => setZoom( Math.max( controllerZoom.min, zoom - 0.1 ) )
+ const zoomInController = () => setZoom( Math.min( CLIENT_OPTIONS.controllerZoom.max, zoom + 0.1 ) )
+ const zoomOutController = () => setZoom( Math.max( CLIENT_OPTIONS.controllerZoom.min, zoom - 0.1 ) )
const zoomResetController = () => setZoom( 1 )
const toggleFullscreenController = () => {
@@ -131,10 +130,10 @@ const Presenter = () => {
}>
- {!( isControllerOpen && controllerOnly ) && }
+ {!( isControllerOpen && controllerOnly ) && }
-
+
diff --git a/apps/frontend/src/app/settings/-components/DynamicOptions.tsx b/apps/frontend/src/app/settings/-components/DynamicOptions.tsx
index 23ba881e..053b8034 100644
--- a/apps/frontend/src/app/settings/-components/DynamicOptions.tsx
+++ b/apps/frontend/src/app/settings/-components/DynamicOptions.tsx
@@ -2,11 +2,10 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Grid, Typography } from '@mui/material'
import { ClientSettings, Settings } from '@presenter/contract'
-import { useContext } from 'react'
-import { SettingsContext } from '~/helpers/contexts'
-import { CLIENT_OPTIONS, DEFAULT_OPTIONS, FLAT_OPTION_GROUPS } from '~/helpers/options'
+import { CLIENT_OPTIONS, FLAT_OPTION_GROUPS } from '~/helpers/options'
import controller from '~/services/controller'
+import { useClientsSettings, useLocalSettings } from '~/services/settings'
import SettingComponentFactory, { Button } from './SettingsComponents'
@@ -85,12 +84,13 @@ type DynamicOptionsProps = {
}
const DynamicOptions = ( { device, group }: DynamicOptionsProps ) => {
- const settings = useContext( SettingsContext )
+ const [ clients ] = useClientsSettings()
+ const [ local ] = useLocalSettings()
- const selectedDeviceSettings = settings[ device ] || settings.local
+ const selectedDeviceSettings = clients[ device ] ?? local
const isGlobal = device === 'global'
- const defaultSettings = isGlobal ? DEFAULT_OPTIONS.global : DEFAULT_OPTIONS.local
+ // const defaultSettings = isGlobal ? DEFAULT_OPTIONS.global : DEFAULT_OPTIONS.local
const setSettings =