Sha256: 132970bc22ad6fdb6bb74687e6c8e8f17baa8f53375894991c6acd347fe58942

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

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

    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 user.avatar.default_multiuser_url unless conversation.interlocutors(user).count == 1

      conversation.interlocutors(user).first.avatar_url
    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

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.24.3 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.24.2 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.24.1 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.24.0 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.24.0.rc2 app/cells/decidim/user_conversations_cell.rb
decidim-core-0.24.0.rc1 app/cells/decidim/user_conversations_cell.rb