about summary refs log tree commit diff
path: root/src/state/lib/api.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-10-04 10:15:35 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-10-04 10:15:35 -0500
commit0296e8411e528ae1c39a5d8231ba2ec89fa2633e (patch)
tree476b1b963eeb957644175c9f1522330f19e87bd3 /src/state/lib/api.ts
parent195d2f7d2bd193108938901c3f757a9e89080b63 (diff)
downloadvoidsky-0296e8411e528ae1c39a5d8231ba2ec89fa2633e.tar.zst
Fixes to entity extraction
Diffstat (limited to 'src/state/lib/api.ts')
-rw-r--r--src/state/lib/api.ts24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/state/lib/api.ts b/src/state/lib/api.ts
index db7e2ab21..ad81301ff 100644
--- a/src/state/lib/api.ts
+++ b/src/state/lib/api.ts
@@ -6,14 +6,9 @@
 // import {ReactNativeStore} from './auth'
 import AdxApi from '../../third-party/api'
 import {ServiceClient} from '../../third-party/api/src/index'
-import {
-  TextSlice,
-  Entity as Entities,
-} from '../../third-party/api/src/types/todo/social/post'
 import {AdxUri} from '../../third-party/uri'
 import {RootStoreModel} from '../models/root-store'
-
-type Entity = Entities[0]
+import {extractEntities} from '../../view/lib/strings'
 
 export function doPolyfill() {
   AdxApi.xrpc.fetch = fetchHandler
@@ -204,20 +199,3 @@ async function iterateAll(
     }
   } while (res.records.length === 100)
 }*/
-
-function extractEntities(text: string): Entity[] | undefined {
-  let match
-  let ents: Entity[] = []
-  const re = /(^|\s)@([a-zA-Z0-9\.-]+)(\b)/g
-  while ((match = re.exec(text))) {
-    ents.push({
-      type: 'mention',
-      value: match[2],
-      index: [
-        match.index + 1, // skip the (^|\s) but include the '@'
-        match.index + 2 + match[2].length,
-      ],
-    })
-  }
-  return ents.length > 0 ? ents : undefined
-}