Skip to content

Commit

Permalink
Fix VerseRefs not working as expected with check ranges (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil authored Nov 27, 2024
1 parent d243d5d commit 1f9a677
Show file tree
Hide file tree
Showing 7 changed files with 3,569 additions and 2,152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ICheckRunner,
SettableCheckDetails,
} from 'platform-scripture';
import { VerseRef } from '@sillsdev/scripture';
import { Canon, ScrVers, VerseRef } from '@sillsdev/scripture';
import { CHECK_RUNNER_NETWORK_OBJECT_TYPE } from './check.model';
import {
aggregateProjectIdsByCheckId,
Expand Down Expand Up @@ -131,6 +131,32 @@ class CheckAggregatorDataProviderEngine
): Promise<DataProviderUpdateInstructions<CheckAggregatorDataTypes>> {
if (!subscriptionId) return false;

// Fix problems when range objects are VerseRefs but not working as expected
ranges.forEach((range) => {
if (!(range.start instanceof VerseRef)) {
// TS says range.start is of type "never", but treat it as a VerseRef with the wrong prototype
// eslint-disable-next-line no-type-assertion/no-type-assertion
const start = range.start as VerseRef;
range.start = new VerseRef(
Canon.bookIdToNumber(start.book),
start.chapterNum,
start.verseNum,
start.versificationStr ? new ScrVers(start.versificationStr) : undefined,
);
}
if (range.end && !(range.end instanceof VerseRef)) {
// TS says range.end is of type "never", but treat it as a VerseRef with the wrong prototype
// eslint-disable-next-line no-type-assertion/no-type-assertion
const end = range.end as VerseRef;
range.end = new VerseRef(
Canon.bookIdToNumber(end.book),
end.chapterNum,
end.verseNum,
end.versificationStr ? new ScrVers(end.versificationStr) : undefined,
);
}
});

// Update the subscription
this.findSubscription(subscriptionId).ranges = ranges;

Expand Down
9 changes: 5 additions & 4 deletions lib/platform-bible-utils/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-utils/dist/index.cjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit 1f9a677

Please sign in to comment.