From 17be82375ecd62de6f5373f6efb8fa4cbf4b5798 Mon Sep 17 00:00:00 2001 From: Harshil Jani Date: Tue, 9 Apr 2024 13:34:58 +0530 Subject: [PATCH] Allow tagging(mention) in Notes with username or display name (#137) Signed-off-by: Harshil-Jani --- src/app/shared/content/content.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/shared/content/content.ts b/src/app/shared/content/content.ts index f4331e2..88e5bcd 100644 --- a/src/app/shared/content/content.ts +++ b/src/app/shared/content/content.ts @@ -298,6 +298,16 @@ export class ContentComponent { } else { i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token.substring(6), token: decoded.type }); } + } else if (token.startsWith('@')) { + const username = token.substring(1); + const npub = this.profileService.following.find((follower) => follower.name === username)?.npub; + if (npub) { + const decoded = nip19.decode(npub); + const val = decoded.data as any; + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val, token: decoded.type }); + } else { + res[i] += token; + } } else if (token.startsWith('http://') || token.startsWith('https://')) { if (this.isImage(token)) { i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token, token: 'image' });