diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 076e1264..728141bd 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -2,6 +2,10 @@ class InboxController < ApplicationController before_filter :authenticate_user! def show - @inbox = Inbox.where(user: current_user).order(:created_at).reverse_order + @inbox = Inbox.where(user: current_user).order(:created_at).reverse_order.paginate(page: params[:page]) + respond_to do |format| + format.html + format.js + end end end diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index 0619f301..ced60bd5 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -8,15 +8,15 @@ - @inbox.each do |i| = render 'inbox/entry', i: i - #pagination= will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false - - - if @inbox.next_page - %button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @inbox.current_page }} - Load more - - if @inbox.empty? - Nothing to see here. + + #pagination= will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false + + - if @inbox.next_page + %button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @inbox.current_page }} + Load more + .col-md-9.col-xs-12.col-sm-9.visible-xs = render 'inbox/sidebar' diff --git a/app/views/inbox/show.js.erb b/app/views/inbox/show.js.erb index 5b6366c9..e2463c02 100644 --- a/app/views/inbox/show.js.erb +++ b/app/views/inbox/show.js.erb @@ -1,8 +1,9 @@ -$('#timeline').append('<% @timeline.each do |answer| - %><%= j render 'inbox/entry', a: answer +$('#entries').append('<% @inbox.each do |i| + %><%= j render 'inbox/entry', i: i %><% end %>'); <% if @timeline.next_page %> $('#pagination').html('<%= j will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false %>'); <% else %> $('#pagination, #load-more-btn').remove(); -<% end %> \ No newline at end of file +<% end %> +<% @inbox.update_all(new: false) %> \ No newline at end of file