Sha256: 0828fcc7fdbbf17a5eb37fc7a132b985065f07846439d4b972d1b35cf94b5414

Contents?: true

Size: 495 Bytes

Versions: 4

Compression:

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

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.13.0 app/commands/thredded/mark_all_read.rb
thredded-0.12.4 app/commands/thredded/mark_all_read.rb
thredded-0.12.3 app/commands/thredded/mark_all_read.rb
thredded-0.12.2 app/commands/thredded/mark_all_read.rb