conversations: fix recipient pagination caching
fixes CNVS-11199 test plan: * open conversations as a user who can message more than twenty other users * open compose dialog * open recipients browser * open context with many users and scroll down * verify that all users load * close and re-open recipients browser * verify that all users are still present Change-Id: Ibeefddc92f49cc52195336eee50d7213e8717d12 Reviewed-on: https://gerrit.instructure.com/36381 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Joel Hough <joel@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Braden Anderson <braden@instructure.com>
This commit is contained in:
parent
b995981ccc
commit
5bd46c8f39
|
@ -97,11 +97,19 @@ define [
|
||||||
# @api private
|
# @api private
|
||||||
|
|
||||||
attachCollection: ->
|
attachCollection: ->
|
||||||
@collection.on 'reset', @renderOnReset
|
@listenTo @collection, 'reset', @renderOnReset
|
||||||
@collection.on 'add', @renderOnAdd
|
@listenTo @collection, 'add', @renderOnAdd
|
||||||
@collection.on 'remove', @removeItem
|
@listenTo @collection, 'remove', @removeItem
|
||||||
@empty = not @collection.length
|
@empty = not @collection.length
|
||||||
|
|
||||||
|
detachCollection: ->
|
||||||
|
@stopListening @collection
|
||||||
|
|
||||||
|
switchCollection: (collection) ->
|
||||||
|
@detachCollection()
|
||||||
|
@collection = collection
|
||||||
|
@attachCollection()
|
||||||
|
|
||||||
##
|
##
|
||||||
# Ensures item views are removed properly
|
# Ensures item views are removed properly
|
||||||
#
|
#
|
||||||
|
|
|
@ -62,13 +62,13 @@ define [
|
||||||
|
|
||||||
attachCollection: ->
|
attachCollection: ->
|
||||||
super
|
super
|
||||||
@collection.on 'reset', @attachScroll
|
@listenTo @collection, 'reset', @attachScroll
|
||||||
@collection.on 'fetched:last', @detachScroll
|
@listenTo @collection, 'fetched:last', @detachScroll
|
||||||
@collection.on 'beforeFetch', @showLoadingIndicator
|
@listenTo @collection, 'beforeFetch', @showLoadingIndicator
|
||||||
if @autoFetch
|
if @autoFetch
|
||||||
@collection.on 'fetch', => setTimeout @checkScroll # next tick so events don't stomp on each other
|
@listenTo @collection, 'fetch', => setTimeout @checkScroll # next tick so events don't stomp on each other
|
||||||
else
|
else
|
||||||
@collection.on 'fetch', @hideLoadingIndicator
|
@listenTo @collection, 'fetch', @hideLoadingIndicator
|
||||||
|
|
||||||
##
|
##
|
||||||
# Sets instance properties regarding the scrollContainer
|
# Sets instance properties regarding the scrollContainer
|
||||||
|
|
|
@ -112,12 +112,11 @@ define [
|
||||||
@$span = @_initializeWidthSpan()
|
@$span = @_initializeWidthSpan()
|
||||||
setTimeout((=> @_disable() if @options.disabled), 0)
|
setTimeout((=> @_disable() if @options.disabled), 0)
|
||||||
@_fetchResults = _.debounce(@__fetchResults, 250)
|
@_fetchResults = _.debounce(@__fetchResults, 250)
|
||||||
@resultCollection = new PaginatedCollection([], model: ConversationSearchResult)
|
|
||||||
@resultView = new PaginatedCollectionView
|
@resultView = new PaginatedCollectionView
|
||||||
el: @$resultContents
|
el: @$resultContents
|
||||||
scrollContainer: @$resultContainer
|
scrollContainer: @$resultContainer
|
||||||
buffer: 50
|
buffer: 50
|
||||||
collection: @resultCollection
|
collection: new Backbone.Collection()
|
||||||
template: null
|
template: null
|
||||||
itemView: Backbone.View.extend
|
itemView: Backbone.View.extend
|
||||||
template: resultTemplate
|
template: resultTemplate
|
||||||
|
@ -135,14 +134,14 @@ define [
|
||||||
id: "result-#{$.guid++}" # for aria-activedescendant
|
id: "result-#{$.guid++}" # for aria-activedescendant
|
||||||
attributes['aria-haspopup'] = @model.get('isContext')
|
attributes['aria-haspopup'] = @model.get('isContext')
|
||||||
attributes
|
attributes
|
||||||
@_attachCollection()
|
|
||||||
|
|
||||||
# Internal: Manage events on the results collection.
|
# Internal: Manage events on the results collection.
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
_attachCollection: ->
|
_attachCollection: ->
|
||||||
@resultCollection.off('reset', @resultView.renderOnReset)
|
@resultView.switchCollection(@resultCollection)
|
||||||
@resultCollection.off('remove', @resultView.removeItem)
|
@resultView.stopListening(@resultCollection, 'reset', @resultView.renderOnReset)
|
||||||
|
@resultView.stopListening(@resultCollection, 'remove', @resultView.removeItem)
|
||||||
|
|
||||||
# Public: Toggle visibility of result list.
|
# Public: Toggle visibility of result list.
|
||||||
#
|
#
|
||||||
|
@ -270,7 +269,6 @@ define [
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
_onSearchResultLoad: =>
|
_onSearchResultLoad: =>
|
||||||
@cache[@currentUrl] = @resultCollection.toJSON()
|
|
||||||
_.extend(@permissions, @_getPermissions())
|
_.extend(@permissions, @_getPermissions())
|
||||||
@_addEveryoneResult(@resultCollection) unless @excludeAll or !@_canSendToAll()
|
@_addEveryoneResult(@resultCollection) unless @excludeAll or !@_canSendToAll()
|
||||||
@resultCollection.each @_addToModelCache
|
@resultCollection.each @_addToModelCache
|
||||||
|
@ -359,13 +357,16 @@ define [
|
||||||
return unless url
|
return unless url
|
||||||
@currentUrl = url
|
@currentUrl = url
|
||||||
if @cache[url]
|
if @cache[url]
|
||||||
@resultCollection.reset(@cache[url])
|
@resultCollection = @cache[url]
|
||||||
|
@_attachCollection()
|
||||||
@toggleResultList(true)
|
@toggleResultList(true)
|
||||||
@_onSearchResultLoad()
|
@_onSearchResultLoad()
|
||||||
else
|
else
|
||||||
@currentRequest = @resultCollection.fetch
|
@resultCollection = new PaginatedCollection([], model: ConversationSearchResult)
|
||||||
url: @url(@$input.val())
|
@resultCollection.url = url
|
||||||
success: @_onSearchResultLoad
|
@cache[url] = @resultCollection
|
||||||
|
@_attachCollection()
|
||||||
|
@currentRequest = @resultCollection.fetch().done(@_onSearchResultLoad)
|
||||||
@toggleResultList(true)
|
@toggleResultList(true)
|
||||||
|
|
||||||
# Internal: Get URL for the current request, caching it as
|
# Internal: Get URL for the current request, caching it as
|
||||||
|
|
Loading…
Reference in New Issue