Fixed compatability issues in methods for thread-like messages
This commit is contained in:
@@ -19,6 +19,7 @@ class MessagerepliesController < ApplicationController
|
||||
if false
|
||||
@reply.send_new_message_reply_mail
|
||||
end
|
||||
Message.find(params[:message_id]).update_attributes(user_hidden: nil, user_unread_id: current_user.id)
|
||||
position = message.replies.count - 1
|
||||
page = position / Kaminari.config.default_per_page + 1
|
||||
redirect_to message_path(@reply.message, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!'
|
||||
|
||||
@@ -17,7 +17,7 @@ class MessagesController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
Message.find(@message.id).update_attributes(user_unread: nil) if @message.user_unread && @message.user_target.is?(current_user)
|
||||
Message.find(@message.id).update_attributes(user_unread: nil) unless @message.user_unread == current_user
|
||||
@replies = @message.replies.page(params[:page])
|
||||
end
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ class Message < ActiveRecord::Base
|
||||
before_destroy :do_destroy?
|
||||
|
||||
def do_destroy?
|
||||
unless user_hidden || user_sender == user_target
|
||||
if user_hidden || user_sender == user_target
|
||||
return true
|
||||
else
|
||||
update_attributes(user_hidden: User.current)
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<%= form_for [reply.get_message, reply] do |f| %>
|
||||
<%= render partial: "md_editor", locals: {name: "messagereply[text]", content: reply.text} %>
|
||||
<%= f.hidden_field :user_unread, value: current_user %>
|
||||
<p><%= f.submit "Reply", class: "btn blue" %></p>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<%= render partial: "users/username", locals: { user: user } %>
|
||||
<span style="font-size:16px">
|
||||
|
||||
<span class="<%= "bold" if message.user_unread && message.user_unread != current_user %>"><%= link_to message.subject, message %></span>
|
||||
<span class="<%= "bold" if message.user_unread_id && message.user_unread != current_user %>"><%= link_to message.subject, message %></span>
|
||||
|
|
||||
</span>
|
||||
<%= ago message.created_at %>
|
||||
|
||||
Reference in New Issue
Block a user