Sha256: 2cc2145a7ecfb0b4332f3a16bb5c259a786f4a60df66be8c2e2f5ff1cdaed11f

Contents?: true

Size: 494 Bytes

Versions: 14

Compression:

Stored size: 494 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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
thredded-0.12.1 app/commands/thredded/mark_all_read.rb
thredded-0.12.0 app/commands/thredded/mark_all_read.rb
thredded-0.11.1 app/commands/thredded/mark_all_read.rb
thredded-0.11.0 app/commands/thredded/mark_all_read.rb
thredded-0.10.1 app/commands/thredded/mark_all_read.rb
thredded-0.10.0 app/commands/thredded/mark_all_read.rb
thredded-0.9.4 app/commands/thredded/mark_all_read.rb
thredded-0.9.3 app/commands/thredded/mark_all_read.rb
thredded-0.9.2 app/commands/thredded/mark_all_read.rb
thredded-0.9.1 app/commands/thredded/mark_all_read.rb
thredded-0.8.4 app/commands/thredded/mark_all_read.rb
thredded-0.8.2 app/commands/thredded/mark_all_read.rb
thredded-0.7.0 app/commands/thredded/mark_all_read.rb
thredded-0.6.3 app/commands/thredded/mark_all_read.rb