Sha256: dc061ce603aea60649a64920a2b6b3e6775249a0ab67106492416693c33988e8

Contents?: true

Size: 505 Bytes

Versions: 14

Compression:

Stored size: 505 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class MarkAllRead
    def self.run(user)
      unread_topics = Thredded::PrivateTopic.unread(user)
      return if unread_topics.empty?

      unread_topics.each do |topic|
        last_post = topic.posts.order_oldest_first.last
        total_pages = topic.posts.page(1).total_pages

        Thredded::UserPrivateTopicReadState.touch!(
          user.id,
          topic.id,
          last_post,
          total_pages
        )
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
threddedDANIEL-0.14.5 app/commands/thredded/mark_all_read.rb
thredded-0.14.4 app/commands/thredded/mark_all_read.rb
thredded-0.14.3 app/commands/thredded/mark_all_read.rb
thredded-0.14.2 app/commands/thredded/mark_all_read.rb
thredded-0.14.1 app/commands/thredded/mark_all_read.rb
thredded-0.14.0 app/commands/thredded/mark_all_read.rb
thredded-0.13.8 app/commands/thredded/mark_all_read.rb
thredded-0.13.7 app/commands/thredded/mark_all_read.rb
thredded-0.13.6 app/commands/thredded/mark_all_read.rb
thredded-0.13.5 app/commands/thredded/mark_all_read.rb
thredded-0.13.4 app/commands/thredded/mark_all_read.rb
thredded-0.13.3 app/commands/thredded/mark_all_read.rb
thredded-0.13.2 app/commands/thredded/mark_all_read.rb
thredded-0.13.1 app/commands/thredded/mark_all_read.rb