Open calebmer opened 5 years ago
So I can see a couple of ways to resolve this:
let's say I have the following post: hey @calebmer can you help me w/ typescript?
for both methods, we will need a search function. to find all possible user mentions and validate if it is a mention to a user or just unrelated text.
let's assume the function does just that, call it findMentions
for now.
@name
with some kind of to represent the user. This will happen on the server upon receiving the string and prior to inserting to the db using the findMentions
function.
["hey ", {user_id:00001, text:"@calebmer"}, "can you help me w/ typescript"]
user_id
findMentions
to have autocomplete on client side (sort of like what slack is doing) findMentions
on every post the user sees. if valid, replace w/ a link. this will cause a lot of db interaction or caching of all users on client side to make it more efficient. personally, I would go for the first option, but if you guys have a different way that you can think of or want me to elaborate on the second option, let me know.
Cheers!
Part of what I’m looking for in this feature and #30 is some specification of how Connect content should be encoded. For instance, how should we encode mentions?
Hello @user#123!
Hello @#123!
Hello <@user#123>!
If we pick any of these then what is our escape character?
I at least want us to decide on an escape character for extra information that is not visible in the text. Since we don’t expect humans to write this, we can get creative with Unicode. We could use the ❰❱ brackets to signify enhanced text content. Like HTML uses <>.
Hello ❰@user#123❱!
For bold content:
Hello ❰b: this is bold❱!
…or we could just use Markdown. But then Markdown has a bunch of features we don’t want. Also, we need features that Markdown doesn’t include like mentions.
Yep! I like your first option. My comment was more pointing out that it doesn’t have to be JSON. We can create our own format if we don‘t like JSON.
Actually, you know what, I like JSON. We can have TypeScript types for it. We’d also end up parsing a custom string into JSON anyway. I retract my idea.
we could definitely use our own encoding, I was thinking array b/c that would be amazingly easy to parse and turn to a component.
each post is an array, say use variable named post
return <TextElement>
post.map(token=>{
if( typeof token === string ) {
return token
}
else{
switch(token.type){
case mention:
return <Mention token={token} />
break; // more stuff here.
}
}
})
</TextElement>
I totally agree. I’m convinced. JSON is better because it is:
I'm very interested to see how this plays out. Mentions are something that I find very interesting and if I can contribute in any way I will.
Please work on this @brenthaertlein 😀
It’s probably a good idea to start with #30 to get the basic framework in place and then move on to mentions.
In posts and comments users should be able to mention other users with
@
. For example:@calebmer how ya doin?
. That should send a notification tocalebmer
’s account and render as a link tocalebmer
’s profile when the post or comment renders.