paranext / paranext-core

Electron client, extension host, and C# library for Paranext
https://paranext.github.io/paranext-core/
MIT License
17 stars 2 forks source link

Change all TS/JS uses of VerseRef and ScriptureReference to SerializedVerseRef #1355

Open lyonsil opened 5 days ago

lyonsil commented 5 days ago

We are currently using VerseRef and ScriptureReference in our TS/JS code to represent a location in scripture. However, they both suffer from problems, albeit different ones.

VerseRef:

ScriptureReference:

SerializedVerseRef already exists and doesn't suffer from any of these problems. Its main downfall is that it doesn't include its own functions to do things like convert a book ID to a book number, but there are helper classes (e.g., Canon) that can help.

Ira, TJ, and I agreed that using SerializedVerseRef is probably best for passing around pointers to scripture locations. In specific cases where we know a VerseRef will stay within a module we can always convert a SerializedVerseRef into a VerseRef to get access to the helper functions.

To Do:

Note that C# code does not need to change. The C# serialization routines already handle VerseRefs appropriately, and C# VerseRef objects don't have the same problems as JS VerseRef objects. The two runtimes handle object types fundamentally differently.