Skip to content

Commit

Permalink
Updated to use scroll groups (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil authored Aug 30, 2024
1 parent 7a17838 commit 92487c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/paratext-bible-text-collection/assets/displayData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon": "",
"moreInfoUrl": "",
"supportUrl": "",
"moreInfoUrl": "https://github.com/paranext/paratext-bible-extensions/tree/main/src/paratext-bible-text-collection",
"supportUrl": "https://github.com/paranext/paratext-bible-extensions/issues",
"localizedDisplayInfo": {
"en": {
"displayName": "Paratext Text Collection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import papi from '@papi/frontend';
import { useSetting, useDialogCallback } from '@papi/frontend/react';
import { useDialogCallback } from '@papi/frontend/react';
import { Fragment, useCallback, useEffect, useMemo } from 'react';
import { IconButton, ScriptureReference, usePromise } from 'platform-bible-react';
import { deepEqual } from 'platform-bible-utils';
Expand Down Expand Up @@ -27,13 +27,12 @@ const getResourceVerseRef = (scrRef: ScriptureReference) => {
return resourceVerseRef;
};

const defaultScrRef: ScriptureReference = { bookNum: 1, chapterNum: 1, verseNum: 1 };

globalThis.webViewComponent = function TextCollectionWebView({
// Project ID of the project that is focused or undefined if no project selected
projectId: expandedProjectId = '',
updateWebViewDefinition,
useWebViewState,
useWebViewScrollGroupScrRef,
}: WebViewProps) {
// Project IDs to show in the text collection
const [projectIds, setProjectIds] = useWebViewState<string[]>('projectIds', []);
Expand All @@ -60,7 +59,7 @@ globalThis.webViewComponent = function TextCollectionWebView({
}, [projectIds, expandedProjectId, updateWebViewDefinition]);

// Current verse reference
const [scrRef] = useSetting('platform.verseRef', defaultScrRef);
const [scrRef] = useWebViewScrollGroupScrRef();
const verseRef = useMemo(() => getResourceVerseRef(scrRef), [scrRef]);

// Keep the title up-to-date
Expand Down Expand Up @@ -101,7 +100,7 @@ globalThis.webViewComponent = function TextCollectionWebView({

const moveProjectUpDownHandler = (directionUp: boolean, projectId: string) => {
const projectIdsCopy = [...projectIds];
const index = projectIdsCopy.findIndex((id) => id === projectId);
const index = projectIdsCopy.findIndex((pid) => pid === projectId);
const newIndex = directionUp ? index - 1 : index + 1;
if (newIndex < 0 || newIndex > projectIdsCopy.length - 1) return;
[projectIdsCopy[index], projectIdsCopy[newIndex]] = [
Expand Down
4 changes: 2 additions & 2 deletions src/paratext-bible-word-list/assets/displayData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon": "",
"moreInfoUrl": "",
"supportUrl": "",
"moreInfoUrl": "https://github.com/paranext/paratext-bible-extensions/tree/main/src/paratext-bible-word-list",
"supportUrl": "https://github.com/paranext/paratext-bible-extensions/issues",
"localizedDisplayInfo": {
"en": {
"displayName": "Paratext Word List",
Expand Down
5 changes: 3 additions & 2 deletions src/paratext-bible-word-list/src/word-list.web-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSetting, useData } from '@papi/frontend/react';
import { useData } from '@papi/frontend/react';
import { WebViewProps } from '@papi/core';
import { ChangeEvent, useEffect, useMemo, useState } from 'react';
import { ComboBox, ScriptureReference, Switch, TextField } from 'platform-bible-react';
Expand Down Expand Up @@ -58,8 +58,9 @@ function newDataNeeded(
globalThis.webViewComponent = function WordListWebView({
projectId,
useWebViewState,
useWebViewScrollGroupScrRef,
}: WebViewProps) {
const [scrRef] = useSetting('platform.verseRef', defaultScrRef);
const [scrRef] = useWebViewScrollGroupScrRef();
const [scope, setScope] = useWebViewState<Scope>('scope', Scope.Book);
const [wordFilter, setWordFilter] = useState<string>('');
const [selectedWord, setSelectedWord] = useState<WordListEntry>();
Expand Down

0 comments on commit 92487c3

Please sign in to comment.