Skip to content

Commit

Permalink
Merge pull request #1926 from tactilenews/1897_remove_unused_chat_com…
Browse files Browse the repository at this point in the history
…ponent

Remove unused Chat component
  • Loading branch information
roschaefer authored Jul 4, 2024
2 parents d3d18f3 + fe0fffc commit c2408a5
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 79 deletions.
23 changes: 0 additions & 23 deletions app/components/chat/chat.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/components/chat_messages_group/chat_messages_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ def id
"contributor-#{@contributor.id}"
end

def conversation_link
messages.first.conversation_link
end

def add_message_link
new_message_path(contributor_id: @contributor, request_id: @request)
end
Expand Down
4 changes: 0 additions & 4 deletions app/components/search_result/search_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def initialize(result: nil)

attr_reader :result

def link
helpers.contributor_request_path(contributor_id: result.contributor_id, id: result.request_id)
end

def type
result.model_name.name
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create
content_type: 'text/plain'
)
if @message.save!
redirect_to contributor_request_path(contributor_id: @contributor, id: @request), flash: { success: I18n.t('message.create.success') }
redirect_to @message.chat_message_link, flash: { success: I18n.t('message.create.success') }
else
render :new_message, flash: { error: I18n.t('message.create.error') }
end
Expand All @@ -24,7 +24,7 @@ def edit; end

def update
if @message.update(text: params[:message][:text], creator: current_user)
redirect_to contributor_request_path(contributor_id: @contributor, id: @request), flash: { success: I18n.t('message.edit.success') }
redirect_to @message.chat_message_link, flash: { success: I18n.t('message.edit.success') }
else
flash.now[:error] = I18n.t('message.edit.error')
render :edit
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

class RequestsController < ApplicationController
before_action :set_request, only: %i[show show_contributor_messages edit update notifications destroy messages_by_contributor stats]
before_action :set_contributor, only: %i[show_contributor_messages]
before_action :set_request, only: %i[show edit update notifications destroy messages_by_contributor stats]
before_action :notifications_params, only: :notifications
before_action :disallow_edit, only: %i[edit update]
before_action :disallow_destroy, only: :destroy
Expand Down Expand Up @@ -65,10 +64,6 @@ def destroy
end
end

def show_contributor_messages
@chat_messages = @contributor.conversation_about(@request)
end

def notifications
last_updated_at = Time.zone.parse(params[:last_updated_at])
message_count = @request.replies.where('created_at >= ?', last_updated_at).count
Expand Down
4 changes: 0 additions & 4 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def contributor
recipient || sender # If there is no recipient, then the message must be inbound and the sender must be a contributor
end

def conversation_link
Rails.application.routes.url_helpers.contributor_request_path(id: request.id, contributor_id: contributor.id)
end

def chat_message_link
Rails.application.routes.url_helpers.conversations_contributor_path(id: contributor, anchor: "message-#{id}")
end
Expand Down
11 changes: 0 additions & 11 deletions app/views/requests/show_contributor_messages.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
end

resources :contributors, only: %i[index show edit update], concerns: :paginatable do
resources :requests, only: %i[show], to: 'requests#show_contributor_messages'

member do
get 'conversations'
post 'message'
Expand Down
14 changes: 0 additions & 14 deletions spec/models/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,6 @@
let(:request) { create(:request, id: 6) }
let(:message) { create(:message, request: request, **params) }

describe '#conversation_link' do
subject { message.conversation_link }

describe 'given a recipient' do
let(:params) { { sender: nil, recipient: contributor, broadcasted: true } }
it { should eq('/contributors/7/requests/6') }
end

describe 'given an inbound message' do
let(:params) { { recipient: nil, sender: contributor } }
it { should eq('/contributors/7/requests/6') }
end
end

describe '#chat_message_link' do
subject { message.chat_message_link }
let(:params) { { id: 8, recipient: nil, sender: contributor } }
Expand Down
7 changes: 0 additions & 7 deletions spec/requests/contributors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
end
end

describe 'GET /requests/:id' do
it 'should be successful' do
get contributor_request_path(id: the_request.id, contributor_id: contributor.id, as: user)
expect(response).to be_successful
end
end

describe 'GET /count' do
let!(:teachers) { create_list(:contributor, 2, tag_list: 'teacher') }

Expand Down
4 changes: 2 additions & 2 deletions spec/requests/messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

it 'redirects to the conversation link the message belongs to' do
subject.call
expect(response).to redirect_to(contributor_request_path(id: request.id, contributor_id: contributor.id))
expect(response).to redirect_to(Message.first.chat_message_link)
end

it 'shows success notification' do
Expand Down Expand Up @@ -51,7 +51,7 @@

it 'redirects to the conversation link the message belongs to' do
subject.call
expect(response).to redirect_to(contributor_request_path(id: message.request_id, contributor_id: message.sender_id))
expect(response).to redirect_to(message.chat_message_link)
end

context 'not manually created message' do
Expand Down

0 comments on commit c2408a5

Please sign in to comment.