Sha256: 867ce4af5f779f7b9e106f4f5518bad5249501a0ab37af7467c2868de7189e6e

Contents?: true

Size: 1.4 KB

Versions: 31

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Decidim
  class UserConversationsCell < Decidim::ViewModel
    include Cell::ViewModel::Partial
    include Decidim::LayoutHelper
    include Decidim::SanitizeHelper
    include CellsPaginateHelper
    include Decidim::Core::Engine.routes.url_helpers
    include Messaging::ConversationHelper
    include ActionView::Helpers::DateHelper
    include Decidim::ApplicationHelper

    def user
      model
    end

    def show
      render :show
    end

    def conversations
      context[:conversations] || []
    end

    def form_ob
      Messaging::MessageForm.new
    end

    def conversation_avatar(conversation)
      return present(user).avatar.default_multiuser_url unless conversation.interlocutors(user).count == 1

      present(conversation.interlocutors(user).first).avatar_url
    end

    def conversation_avatar_alt(conversation)
      return t("decidim.author.avatar_multiuser") unless conversation.interlocutors(user).count == 1

      t("decidim.author.avatar", name: decidim_sanitize(conversation.interlocutors(user).first.name))
    end

    def conversation_interlocutors(conversation)
      return username_list(conversation.interlocutors(user), shorten: true) unless conversation.interlocutors(user).count == 1

      "#{conversation.interlocutors(user).first.name} <span class=\"muted\">@#{conversation.interlocutors(user).first.nickname}</span>"
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.8 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.7 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.6 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.10 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.9 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.5 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.8 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.4 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.3 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.7 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.5 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.2 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.1 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.4 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.0 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.3 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.0.rc2 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.27.0.rc1 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.26.2 app/cells/decidim/user_conversations_cell.rb