Browse Source

Recent viewed are available at initial load.

Martin Edenhofer 10 years ago
parent
commit
87c91152a7

+ 1 - 1
app/controllers/recent_viewed_controller.rb

@@ -19,7 +19,7 @@ curl http://localhost/api/v1/recent_viewed -v -u #{login}:#{password} -H "Conten
 =end
 
   def index
-    recent_viewed = RecentView.list_fulldata( current_user, 10 )
+    recent_viewed = RecentView.list_full( current_user, 10 )
 
     # return result
     render :json => recent_viewed

+ 3 - 0
app/controllers/sessions/collection_base.rb

@@ -13,6 +13,9 @@ module ExtraCollection
     collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 20)
     assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
 
+    collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
+    assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
+
     collections[ Role.to_app_model ] = []
     Role.all.each {|item|
       assets = item.assets(assets)

+ 4 - 4
app/models/recent_view.rb

@@ -46,20 +46,20 @@ class RecentView < ApplicationModel
     list
   end
 
-  def self.list_fulldata( user, limit = 10 )
+  def self.list_full( user, limit = 10 )
     recent_viewed = self.list( user, limit )
 
     # get related object
     assets = ApplicationModel.assets_of_object_list(recent_viewed)
 
     return {
-      :recent_viewed => recent_viewed,
-      :assets        => assets,
+      :stream => recent_viewed,
+      :assets => assets,
     }
   end
 
   def notify_clients
-    data = RecentView.list_fulldata( User.find(self.created_by_id), 10 )
+    data = RecentView.list_full( User.find(self.created_by_id), 10 )
     Sessions.send_to(
       self.created_by_id,
       {