diff --git a/app/controllers/cards/watches_controller.rb b/app/controllers/cards/watches_controller.rb index 7308c2279..e1c181335 100644 --- a/app/controllers/cards/watches_controller.rb +++ b/app/controllers/cards/watches_controller.rb @@ -1,6 +1,10 @@ class Cards::WatchesController < ApplicationController include CardScoped + def show + fresh_when etag: @card.watch_for(Current.user) + end + def create @card.watch_by Current.user end diff --git a/app/models/card/watchable.rb b/app/models/card/watchable.rb index 2d23868bf..17235529e 100644 --- a/app/models/card/watchable.rb +++ b/app/models/card/watchable.rb @@ -9,7 +9,11 @@ module Card::Watchable end def watched_by?(user) - watchers.include?(user) + watch_for(user)&.watching? + end + + def watch_for(user) + watches.find_by(user: user) end def watch_by(user)