Skip to content

Commit cf64f5b

Browse files
Minor adjustments
1 parent c490259 commit cf64f5b

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/__tests__/store/analysisSlice.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import type {
1010
} from 'interlinearizer';
1111
import { createAnalysisStore } from '../../store';
1212
import { makePhraseLink } from '../test-helpers';
13+
import { emptyAnalysis } from '../../types/empty-factories';
1314
import {
1415
createPhrase,
15-
defaultAnalysis,
1616
defaultState,
1717
deletePhrase,
1818
mergePhrases,
@@ -49,7 +49,7 @@ function makeApprovedLink(ta: TokenAnalysis): TokenAnalysisLink {
4949
*/
5050
function makeAnalysis(ta: TokenAnalysis): TextAnalysis {
5151
return {
52-
...defaultAnalysis,
52+
...emptyAnalysis(),
5353
tokenAnalyses: [ta],
5454
tokenAnalysisLinks: [makeApprovedLink(ta)],
5555
};
@@ -67,7 +67,7 @@ describe('setAnalysis', () => {
6767

6868
it('does not mutate analysisLanguage', () => {
6969
const store = createAnalysisStore({ analysis: { ...defaultState, analysisLanguage: 'fr' } });
70-
store.dispatch(setAnalysis(defaultAnalysis));
70+
store.dispatch(setAnalysis(emptyAnalysis()));
7171
expect(store.getState().analysis.analysisLanguage).toBe('fr');
7272
});
7373
});
@@ -82,7 +82,7 @@ describe('writeGloss', () => {
8282
};
8383
const store = createAnalysisStore({
8484
analysis: {
85-
analysis: { ...defaultAnalysis, tokenAnalysisLinks: [orphanLink] },
85+
analysis: { ...emptyAnalysis(), tokenAnalysisLinks: [orphanLink] },
8686
analysisLanguage: 'und',
8787
},
8888
});
@@ -102,7 +102,7 @@ describe('writeGloss', () => {
102102
};
103103
const store = createAnalysisStore({
104104
analysis: {
105-
analysis: { ...defaultAnalysis, tokenAnalysisLinks: [orphanLink] },
105+
analysis: { ...emptyAnalysis(), tokenAnalysisLinks: [orphanLink] },
106106
analysisLanguage: 'und',
107107
},
108108
});
@@ -159,7 +159,7 @@ describe('selectApprovedGloss', () => {
159159
*/
160160
function makeAnalysisWithPhrase(link: PhraseAnalysisLink): TextAnalysis {
161161
return {
162-
...defaultAnalysis,
162+
...emptyAnalysis(),
163163
phraseAnalyses: [{ id: link.analysisId, surfaceText: 'phrase' }],
164164
phraseAnalysisLinks: [link],
165165
};
@@ -288,7 +288,7 @@ describe('deletePhrase', () => {
288288
const store = createAnalysisStore({
289289
analysis: {
290290
analysis: {
291-
...defaultAnalysis,
291+
...emptyAnalysis(),
292292
phraseAnalyses: [
293293
{ id: 'phrase-1', surfaceText: 'A' },
294294
{ id: 'phrase-2', surfaceText: 'B' },
@@ -316,7 +316,7 @@ describe('mergePhrases', () => {
316316
const store = createAnalysisStore({
317317
analysis: {
318318
analysis: {
319-
...defaultAnalysis,
319+
...emptyAnalysis(),
320320
phraseAnalyses: [
321321
{ id: 'phrase-1', surfaceText: 'A' },
322322
{ id: 'phrase-2', surfaceText: 'B' },
@@ -377,7 +377,7 @@ describe('mergePhrases', () => {
377377
const store = createAnalysisStore({
378378
analysis: {
379379
analysis: {
380-
...defaultAnalysis,
380+
...emptyAnalysis(),
381381
phraseAnalyses: [{ id: 'phrase-1', surfaceText: 'A' }],
382382
phraseAnalysisLinks: [phrase],
383383
},
@@ -436,7 +436,7 @@ describe('selectPhraseLinks', () => {
436436
status: 'suggested',
437437
};
438438
const analysis: TextAnalysis = {
439-
...defaultAnalysis,
439+
...emptyAnalysis(),
440440
phraseAnalyses: [
441441
{ id: 'phrase-1', surfaceText: 'A' },
442442
{ id: 'phrase-2', surfaceText: 'B' },

src/components/AnalysisStore.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { ReactNode } from 'react';
55
import { Provider as ReduxProvider, useDispatch, useSelector, useStore } from 'react-redux';
66
import {
77
createPhrase,
8-
defaultAnalysis,
98
deletePhrase,
109
mergePhrases,
1110
selectAnalysis,
@@ -18,6 +17,7 @@ import {
1817
writePhraseGloss,
1918
} from '../store/analysisSlice';
2019
import { createAnalysisStore, type AnalysisDispatch, type AnalysisRootState } from '../store';
20+
import { emptyAnalysis } from '../types/empty-factories';
2121

2222
// #region Internal context
2323

@@ -86,7 +86,7 @@ export function AnalysisStoreProvider({
8686
const storeRef = useRef<ReturnType<typeof createAnalysisStore> | undefined>(undefined);
8787
if (!storeRef.current) {
8888
storeRef.current = createAnalysisStore({
89-
analysis: { analysis: initialAnalysis ?? defaultAnalysis, analysisLanguage },
89+
analysis: { analysis: initialAnalysis ?? emptyAnalysis(), analysisLanguage },
9090
});
9191
}
9292
const store = storeRef.current;

src/components/InterlinearNavContext.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ export interface InterlinearNav {
131131
*/
132132
reportSettled: () => void;
133133
/**
134-
* Aborts an in-flight cross-book fade and reveals the content immediately. Called by the loader
135-
* when the new book fails to load, so the error is shown rather than left hidden behind a curtain
136-
* that will never receive a settle.
134+
* Aborts an in-flight cross-book fade and reveals the content without waiting for a settle (the
135+
* reveal still animates through the wrapper's opacity transition). Called by the loader when the
136+
* new book fails to load, so the error is shown rather than left hidden behind a curtain that
137+
* will never receive a settle.
137138
*/
138139
cancelFade: () => void;
139140
}

src/store/analysisSlice.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ interface WritePhraseGlossPayload {
7979

8080
// #region Default state
8181

82-
/** Empty `TextAnalysis` used when no `initialAnalysis` is provided to the store. */
83-
export const defaultAnalysis: TextAnalysis = emptyAnalysis();
84-
8582
/** Default `AnalysisState` used as the Redux initial state. */
8683
export const defaultState: AnalysisState = {
87-
analysis: { ...defaultAnalysis },
84+
analysis: emptyAnalysis(),
8885
analysisLanguage: 'und',
8986
};
9087

0 commit comments

Comments
 (0)