Skip to content

Commit

Permalink
Allow tagging(mention) in Notes with username or display name (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Harshil-Jani <[email protected]>
  • Loading branch information
Harshil-Jani authored Apr 9, 2024
1 parent 3fcd7fe commit 17be823
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/shared/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down

0 comments on commit 17be823

Please sign in to comment.