Provide feedback when a user tries to double-reshare
This commit is contained in:
parent
99aafb18cd
commit
00885be738
6 changed files with 27 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ class ResharesController < ApplicationController
|
|||
|
||||
def create
|
||||
@reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid])
|
||||
if @reshare.save!
|
||||
if @reshare.save
|
||||
current_user.add_to_streams(@reshare, current_user.aspects)
|
||||
current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root.author)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,2 +1,9 @@
|
|||
module ResharesHelper
|
||||
def reshare_error_message(reshare)
|
||||
if @reshare.errors[:root_guid].present?
|
||||
escape_javascript(@reshare.errors[:root_guid].first)
|
||||
else
|
||||
escape_javascript(t('reshares.create.failure'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
<% if @reshare.persisted? %>
|
||||
$('.stream_element#<%=params[:root_guid]%>').addClass('reshared');
|
||||
ContentUpdater.addPostToStream(
|
||||
"<%= escape_javascript(render(:partial => 'shared/stream_element', :locals => {:post => @reshare }))=%>"
|
||||
);
|
||||
<% else %>
|
||||
Diaspora.widgets.flashes.render({success:false,
|
||||
notice: "<%= reshare_error_message(@reshare) %>"});
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -26,3 +26,4 @@
|
|||
attributes:
|
||||
from_id:
|
||||
taken: "is a duplicate of a pre-existing request."
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,10 @@ en:
|
|||
attributes:
|
||||
from_id:
|
||||
taken: "is a duplicate of a pre-existing request."
|
||||
|
||||
|
||||
reshare:
|
||||
attributes:
|
||||
root_guid:
|
||||
taken: "You've already reshared that post!"
|
||||
error_messages:
|
||||
helper:
|
||||
invalid_fields: "Invalid Fields"
|
||||
|
|
@ -579,7 +581,9 @@ en:
|
|||
few: "%{count} new requests!"
|
||||
many: "%{count} new requests!"
|
||||
other: "%{count} new requests!"
|
||||
|
||||
reshares:
|
||||
create:
|
||||
failure: "There was an error resharing this post."
|
||||
services:
|
||||
index:
|
||||
logged_in_as: "logged in as"
|
||||
|
|
|
|||
|
|
@ -47,3 +47,5 @@ en:
|
|||
comments:
|
||||
show: "show all comments"
|
||||
hide: "hide comments"
|
||||
reshares:
|
||||
duplicate:"You've already reshared that post!"
|
||||
|
|
|
|||
Loading…
Reference in a new issue