Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I think it's not possible if devrant stores the comment and the username (of the person being mentioned) on a single database column.
-
What if...
When you type @username the comment only stores a user ID. Whenever the comment is loaded, you search for the username by the ID.
When the user changes his username, the string in the table accessed by the user id will be changed. And whenever a comment with @ is loaded, you dereference the ID and find the username which is always up to date.
Don't know how expensive this would be. I guess the biggest problem will be to find the user id by a string when posting a new comment with a mention -
@stimulate that's what I think also. But it would somehow slow down the retrieval of comments since it would do another 'task' which is to search the user. 🤔
-
@stimulate but you could maybe optimize it by only searching for the users who have already posted on the rant at first. If the username to be mentioned is outside of the rant you will have to go all the way to fetch the ID tho..
-
@stimulate good point! Thanks for the input. I think you just solved my problem on one of my projects. I love this app man. 🤗
-
@vinceurag IDs are often a great solution. Instead of storing all the data in an object and always having to push around this whole pile of data but only using half of it, you store all data in a bunch of arrays. So you have an array of all usernames, one for user descriptions, one for ++'s... And the "User"-object only stores indices into those arrays (tho you have to mind that this only makes sense if the data the index is for is bigger than an int or whatever type you are using for the index)
-
dfox428278yI think this is a valid point, but like some have pointed out, it would be very difficult to change it since usernames are just normal comment text that gets parsed when we read them.
I'm also not sure if it would be the best behavior to change pre-existing rants. It opens up room for abuse. Someone can theoretically change their username to something a user wouldn't have wanted to mention in a comment. Not likely, but still a possibility.
I think at the very least we can put a warning on the change username screen telling you that comments where you were mentioned will no longer link to your profile. And we already say that someone can take your username right away if they want to. -
@dfox fair enough. I was thinking perhaps a hack for it could be to utilize the notifications. When a "mentioned you in a comment" notification is sent, it has to have the target username and reference to the original rant/comment in question. Perhaps that could be persisted in a one to many relationship going from user to the rant/comment with the mention in it. Then have a scheduled batch job that looks for usernames that changed in the past 24 (or however many) hours and looks at that persisted map to update the rants in question. By doing that, you don't need to change how comments and rants are parsed. A little hacky but would work.
I do understand your concerns regarding abuse. My one question is on setting up a username, do you validate it for a preset list of phrases? IE not allowing curses or insults? Because if you are concerned with users not wanting to mention a certain username, maybe that username should not be allowed to start with.
Related Rants
-
tankerkiller12514Ok is it just me or do GIF never fucking load on Android here on devRant? Like wtf I have a high speed LTE con...
-
Skayo5Error 404: ++'s not found.
-
ElizadeathRaven13It’s just me or copy-past options in DevRant app appear with Kanji? Why? Even if I open my photo gallery to ...
@DFox @trogus found a bug- not sure how easy it will be to fix... if you change your username, mentions in rants and comments still have the old username which will be confusing for people trying to figure out who the mention is for.
Is it possible that on editing a username, all mentions in all comments and rants are renamed as well?
undefined
devrant bug?