Fix NewPost typing by preserving spaces while stripping bible tokens
This commit is contained in:
@@ -9,7 +9,7 @@ import Media from '../components/Media';
|
|||||||
import { Platform } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
import { useSnapshot } from 'valtio';
|
import { useSnapshot } from 'valtio';
|
||||||
import GlobalState from '../contexts/GlobalState.js';
|
import GlobalState from '../contexts/GlobalState.js';
|
||||||
import { createBibleToken, extractBibleReferences, stripBibleTokens } from '../utils/bibleReferences.js';
|
import { createBibleToken, extractBibleReferences } from '../utils/bibleReferences.js';
|
||||||
|
|
||||||
const BATCH_SIZE = 1; // Constant for batch size
|
const BATCH_SIZE = 1; // Constant for batch size
|
||||||
|
|
||||||
@@ -63,8 +63,13 @@ let NewPostView = (props) => {
|
|||||||
GlobalState.biblePickerSelection = null;
|
GlobalState.biblePickerSelection = null;
|
||||||
}, [biblePickerSelectionTs]);
|
}, [biblePickerSelectionTs]);
|
||||||
|
|
||||||
|
const removeBibleTokensFromDraft = (value = "") => {
|
||||||
|
return String(value || "").replace(/@bible:[^\s]+/gi, "");
|
||||||
|
};
|
||||||
|
|
||||||
const handlePostContentChange = (nextValue = "") => {
|
const handlePostContentChange = (nextValue = "") => {
|
||||||
const detectedReferences = extractBibleReferences(nextValue);
|
const incomingValue = String(nextValue || "");
|
||||||
|
const detectedReferences = extractBibleReferences(incomingValue);
|
||||||
if (detectedReferences.length) {
|
if (detectedReferences.length) {
|
||||||
setBibleReferences((prev) => {
|
setBibleReferences((prev) => {
|
||||||
const seen = new Set(prev);
|
const seen = new Set(prev);
|
||||||
@@ -72,7 +77,7 @@ let NewPostView = (props) => {
|
|||||||
return Array.from(seen);
|
return Array.from(seen);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setPostContent(stripBibleTokens(nextValue));
|
setPostContent(removeBibleTokensFromDraft(incomingValue));
|
||||||
};
|
};
|
||||||
|
|
||||||
const pickImage = async () => {
|
const pickImage = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user