Permalink
Browse files

fix async on stream

  • Loading branch information...
1 parent 9e76804 commit 02ad4ace5f427fc8b37ba363ad85b863dcc12154 jon committed Dec 12, 2012
View
@@ -17,7 +17,7 @@ class Admin
property :salt, String
property :hashed_password, String
property :created_at, DateTime, default: DateTime.now
- property :upadted_at, DateTime
+ property :updated_at, DateTime
property :access_level, Integer
def username= new_username
@@ -10,7 +10,7 @@ class TokenPair
property :expires_in, Integer
property :issued_at, Integer
property :created_at, DateTime, default: DateTime.now
- property :upadted_at, DateTime
+ property :updated_at, DateTime
def update_token!(object)
self.refresh_token = object.refresh_token
View
@@ -29,7 +29,7 @@ class Link #from http://datamapper.org/docs/associations.html
property :session_id, String
property :hashed_password, String
property :created_at, DateTime, default: DateTime.now
- property :upadted_at, DateTime
+ property :updated_at, DateTime
property :last_stream_request, DateTime
def username= new_username
@@ -49,7 +49,7 @@ def to_hash
email: self.email,
session_id: self.session_id,
created_at: self.created_at,
- upadted_at: self.upadted_at,
+ updated_at: self.updated_at,
last_stream_request: self.last_stream_request}
end
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
View
@@ -98,7 +98,7 @@
if user
## if valid user, then update new stream items
## for now just grabbing new events
- events = user.stream_events(100)
+ events = user.stream_events(100).uniq
events.each do |event|
element = render_pane({title: event.title,
classes: event.category.name,
@@ -72,4 +72,38 @@
}
});
});
+ });
+
+ $(function() {
+ var loop = true;
+ var $container = $('#isotope-container');
+ function update_stream_content() {
+ if (loop) {
+ var now = Date();
+ $.ajax({
+ type: "POST",
+ url: "/api/user/stream/update",
+ data: {user_id: "#{@user.id}",
+ user_salt: "#{@user.salt}",
+ time: now,
+ range: "0 10"}
+ }).done(function (response) {
+ if (response.length > 0) {
+ var html = $('<div>').html(response);
+ // add the new elements to the isotope container
+ $container.prepend(html).isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' });
+ // add the click handlers for the new elements
+ $('.element').click(function(e) {
+ if ($(e.target).hasClass('event-load-btn')) {
+ } else {
+ $(this).toggleClass('large');
+ $container.isotope('reLayout');
+ }
+ });
+ }
+ });
+ setTimeout(update_stream_content, 10000);
+ }
+ };
+ doStuff();
});

0 comments on commit 02ad4ac

Please sign in to comment.