Commit 57d5ba07 by Ibrahim Awwal

Remove commented out block and pull some stuff into a function to load the first…

Remove commented out block and pull some stuff into a function to load the first page of results for a thread query.
parent 91de5633
...@@ -262,7 +262,6 @@ if Backbone? ...@@ -262,7 +262,6 @@ if Backbone?
@retrieveAllThreads() @retrieveAllThreads()
else if discussionId == "#following" else if discussionId == "#following"
@retrieveFollowed(event) @retrieveFollowed(event)
# Retrieve following
else else
discussionIds = _.map item.find(".board-name[data-discussion_id]"), (board) -> $(board).data("discussion_id").id discussionIds = _.map item.find(".board-name[data-discussion_id]"), (board) -> $(board).data("discussion_id").id
@retrieveDiscussions(discussionIds) @retrieveDiscussions(discussionIds)
...@@ -284,39 +283,27 @@ if Backbone? ...@@ -284,39 +283,27 @@ if Backbone?
retrieveDiscussions: (discussion_ids) -> retrieveDiscussions: (discussion_ids) ->
@discussionIds = discussion_ids.join(',') @discussionIds = discussion_ids.join(',')
@mode = 'commentables' @mode = 'commentables'
@collection.current_page = 0 @retrieveFirstPage()
@collection.reset()
@loadMorePages()
# url = DiscussionUtil.urlFor("search")
# DiscussionUtil.safeAjax
# data: { 'commentable_ids': @discussionIds }
# url: url
# type: "GET"
# success: (response, textStatus) =>
# @collection.current_page = response.page
# @collection.pages = response.num_pages
# @collection.reset(response.discussion_data)
# Content.loadContentInfos(response.annotated_content_info)
# @displayedCollection.reset(@collection.models)
retrieveAllThreads: () -> retrieveAllThreads: () ->
@mode = 'all' @mode = 'all'
@retrieveFirstPage()
retrieveFirstPage: (event)->
@collection.current_page = 0 @collection.current_page = 0
@collection.reset() @collection.reset()
@loadMorePages() @loadMorePages(event)
sortThreads: (event) -> sortThreads: (event) ->
@$(".sort-bar a").removeClass("active") @$(".sort-bar a").removeClass("active")
$(event.target).addClass("active") $(event.target).addClass("active")
@sortBy = $(event.target).data("sort") @sortBy = $(event.target).data("sort")
@collection.reset()
@collection.current_page = 0
@displayedCollection.comparator = switch @sortBy @displayedCollection.comparator = switch @sortBy
when 'date' then @displayedCollection.sortByDateRecentFirst when 'date' then @displayedCollection.sortByDateRecentFirst
when 'votes' then @displayedCollection.sortByVotes when 'votes' then @displayedCollection.sortByVotes
when 'comments' then @displayedCollection.sortByComments when 'comments' then @displayedCollection.sortByComments
@loadMorePages(event) @retrieveFirstPage(event)
#@displayedCollection.sort() # This should be called automatically and calling manually makes the loading indicator go away
performSearch: (event) -> performSearch: (event) ->
if event.which == 13 if event.which == 13
...@@ -392,6 +379,4 @@ if Backbone? ...@@ -392,6 +379,4 @@ if Backbone?
retrieveFollowed: (event)=> retrieveFollowed: (event)=>
@mode = 'followed' @mode = 'followed'
@collection.reset() @retrieveFirstPage(event)
@collection.current_page = 0
@loadMorePages(event)
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