Commit 0b21c9a2 by Ibrahim Awwal

I think this fixes the "Load more" button showing up when there's nothing more to load.

parent b2b2ef17
...@@ -69,9 +69,9 @@ if Backbone? ...@@ -69,9 +69,9 @@ if Backbone?
new_threads = [new Thread(data) for data in response.threads][0] new_threads = [new Thread(data) for data in response.threads][0]
new_collection = _.union(models, new_threads) new_collection = _.union(models, new_threads)
Content.loadContentInfos(response.annotated_content_info) Content.loadContentInfos(response.annotated_content_info)
@reset new_collection
@pages = response.num_pages @pages = response.num_pages
@current_page = response.page @current_page = response.page
@reset new_collection
sortByDate: (thread) -> sortByDate: (thread) ->
thread.get("created_at") thread.get("created_at")
......
...@@ -276,7 +276,6 @@ if Backbone? ...@@ -276,7 +276,6 @@ if Backbone?
@collection.pages = response.num_pages @collection.pages = response.num_pages
@collection.reset(response.threads) @collection.reset(response.threads)
Content.loadContentInfos(response.annotated_content_info) Content.loadContentInfos(response.annotated_content_info)
@displayedCollection.reset(@collection.models)# Don't think this is necessary because it's called on collection.reset
if callback? if callback?
callback() callback()
...@@ -291,6 +290,7 @@ if Backbone? ...@@ -291,6 +290,7 @@ if Backbone?
retrieveFirstPage: (event)-> retrieveFirstPage: (event)->
@collection.current_page = 0 @collection.current_page = 0
@collection.pages = 0
@collection.reset() @collection.reset()
@loadMorePages(event) @loadMorePages(event)
...@@ -337,10 +337,10 @@ if Backbone? ...@@ -337,10 +337,10 @@ if Backbone?
success: (response, textStatus) => success: (response, textStatus) =>
if textStatus == 'success' if textStatus == 'success'
# TODO: Augment existing collection? # TODO: Augment existing collection?
@collection.reset(response.threads)
Content.loadContentInfos(response.annotated_content_info)
@collection.current_page = response.page @collection.current_page = response.page
@collection.pages = response.num_pages @collection.pages = response.num_pages
@collection.reset(response.threads)
Content.loadContentInfos(response.annotated_content_info)
# TODO: Perhaps reload user info so that votes can be updated. # TODO: Perhaps reload user info so that votes can be updated.
# In the future we might not load all of a user's votes at once # In the future we might not load all of a user's votes at once
# so this would probably be necessary anyway # so this would probably be necessary anyway
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment