Permalink
Browse files

Provide feedback when a user tries to double-reshare

  • Loading branch information...
1 parent 99aafb1 commit 00885be738a2e737e7ed18d016eb7a537213d49e Raphael Sofaer committed Jul 23, 2011
@@ -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 @@
-$('.stream_element#<%=params[:root_guid]%>').addClass('reshared');
-ContentUpdater.addPostToStream(
- "<%= escape_javascript(render(:partial => 'shared/stream_element', :locals => {:post => @reshare }))=%>"
-);
+<% 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!"

0 comments on commit 00885be

Please sign in to comment.