Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Starred message can't be re-starred after the first time until client is refreshed

Open danielbressan opened this issue 10 years ago • 2 comments

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.

danielbressan avatar Jul 28 '16 19:07 danielbressan

Finally found some time to take a look at this. There were two problems:

  1. 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.

  2. 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

danielbressan avatar Aug 31 '16 16:08 danielbressan

@karlprieb this still happens on demo server

MartinSchoeler avatar Mar 27 '17 19:03 MartinSchoeler