Starred message can't be re-starred after the first time until client is refreshed
Rocket.Chat version: 0.35.0
If you star and unstar a message, the star stays filled and can't be starred again until the client refreshes.
Finally found some time to take a look at this. There were two problems:
-
After starring and unstarring, if you're the only one that starred the message, it leaves a blank array which is truthy. In the star-message "MessageAction" validation - "and not message.starred" will always be false then.
-
In the same situation if you're not the only person to star the message, the array will contain everyone who starred, which again will resolve false in validation.
Not sure if it's the best fix, but these lines can be added in star validation:
if message.starred and message.starred.length < 1 #for when you're the only person to star
message.starred = undefined
else if (!(Array.isArray(message.starred)))
#for a page refresh, a single person star is an object not an array, so do nothing
else if (_.chain(message.starred).pluck("_id").indexOf(Meteor.userId()).value() < 0) #for when others have it starred
message.starred = undefined
@karlprieb this still happens on demo server