Sha256: 9298477fb614499ca85fe9fb87ff8798d1e10ceb298240c82e58659d34723a74

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    module ProposalMCellOverride
      extend ActiveSupport::Concern

      included do
        # rubocop:disable Metrics/CyclomaticComplexity
        def cache_hash
          hash = []
          hash << I18n.locale.to_s
          hash << model.cache_key_with_version
          hash << model.proposal_votes_count
          hash << model.extra_fields&.vote_weight_totals
          hash << model.endorsements_count
          hash << model.comments_count
          hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
          hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
          hash << render_space? ? 1 : 0
          if current_user
            hash << current_user.cache_key_with_version
            hash << current_user.follows?(model) ? 1 : 0
          end
          hash << model.follows_count
          hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
          hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
          hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
          hash << has_footer?
          hash << has_actions?

          hash.join(Decidim.cache_key_separator)
        end
        # rubocop:enable Metrics/CyclomaticComplexity
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.10.2 app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb
decidim-decidim_awesome-0.10.1 app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb
decidim-decidim_awesome-0.10.0 app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb