chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
Mention suggestions match handles from their start
web/src/lib/molecules/MarkdownField.svelte+9−4
| @@ -20,7 +20,7 @@ | ||
* A picture pasted or dropped in, with a `repo`, is uploaded and linked | ||
* where it went, and its blob added to `images`, to attach. Typing `@` | ||
* suggests whom to mention: those in the thread, then whom the viewer | ||
* follows, then the owners whose handles match. | ||
* follows, then the owners, each whose handle starts with what follows it. | ||
*/ | ||
let { | ||
value = $bindable(''), | ||
| @@ -124,11 +124,16 @@ | ||
: null | ||
]); | ||
if (signal.aborted) return; | ||
const near = [...people, ...followed].filter((a) => a.handle.toLowerCase().includes(q)); | ||
const all = [...near, ...(owners?.owners ?? []).map((o) => o.owner)]; | ||
const all = [...people, ...followed, ...(owners?.owners ?? []).map((o) => o.owner)]; | ||
const seen = new Set<string>(me ? [me] : []); | ||
found = all | ||
.filter((a) => !a.handle.startsWith('did:') && !seen.has(a.did) && !!seen.add(a.did)) | ||
.filter( | ||
(a) => | ||
a.handle.toLowerCase().startsWith(q) && | ||
!a.handle.startsWith('did:') && | ||
!seen.has(a.did) && | ||
!!seen.add(a.did) | ||
) | ||
.slice(0, SUGGESTED); | ||
at = 0; | ||
}, 120); | ||