Mailspring/spec-nylas/database-view-spec.coffee

375 lines
16 KiB
CoffeeScript
Raw Normal View History

_ = require 'underscore'
EventEmitter = require('events').EventEmitter
proxyquire = require 'proxyquire'
Label = require '../src/flux/models/label'
Thread = require '../src/flux/models/thread'
Message = require '../src/flux/models/message'
DatabaseStore = require '../src/flux/stores/database-store'
DatabaseView = proxyquire '../src/flux/stores/database-view',
DatabaseStore: DatabaseStore
describe "DatabaseView", ->
beforeEach ->
@queries = []
spyOn(DatabaseStore, 'run').andCallFake (query) =>
new Promise (resolve, reject) =>
query.resolve = resolve
@queries.push(query)
describe "constructor", ->
it "should require a model class", ->
expect(( -> new DatabaseView())).toThrow()
expect(( -> new DatabaseView(Thread))).not.toThrow()
view = new DatabaseView(Thread)
expect(view.klass).toBe(Thread)
it "should optionally populate matchers and includes", ->
config =
matchers: [Message.attributes.namespaceId.equal('asd')]
includes: [Message.attributes.body]
view = new DatabaseView(Message, config)
expect(view._matchers).toEqual(config.matchers)
expect(view._includes).toEqual(config.includes)
it "should optionally populate ordering", ->
config =
orders: [Message.attributes.date.descending()]
view = new DatabaseView(Message, config)
expect(view._orders).toEqual(config.orders)
it "should optionally accept a metadata provider", ->
provider = ->
view = new DatabaseView(Message, {}, provider)
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
expect(view._metadataProvider).toEqual(provider)
it "should initialize the row count to -1", ->
view = new DatabaseView(Message)
expect(view.count()).toBe(-1)
it "should immediately start fetching a row count", ->
config =
matchers: [Message.attributes.namespaceId.equal('asd')]
view = new DatabaseView(Message, config)
# Count query
expect(@queries[0]._count).toEqual(true)
expect(@queries[0]._matchers).toEqual(config.matchers)
describe "instance methods", ->
beforeEach ->
config =
matchers: [Message.attributes.namespaceId.equal('asd')]
@view = new DatabaseView(Message, config)
@view._pages =
0:
items: [new Thread(id: 'a'), new Thread(id: 'b'), new Thread(id: 'c')]
metadata: {'a': 'a-metadata', 'b': 'b-metadata', 'c': 'c-metadata'}
loaded: true
1:
items: [new Thread(id: 'd'), new Thread(id: 'e'), new Thread(id: 'f')]
metadata: {'d': 'd-metadata', 'e': 'e-metadata', 'f': 'f-metadata'}
loaded: true
@view._count = 1
spyOn(@view, 'invalidateRetainedRange').andCallFake ->
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
describe "setMetadataProvider", ->
it "should empty the page cache and re-fetch all pages", ->
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
@view.setMetadataProvider( -> false)
expect(@view._pages).toEqual({})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
describe "setMatchers", ->
it "should reset the row count", ->
@view.setMatchers([])
expect(@view._count).toEqual(-1)
it "should empty the page cache and re-fetch all pages", ->
@view.setMatchers([])
expect(@view._pages).toEqual({})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
describe "setIncludes", ->
it "should empty the page cache and re-fetch all pages", ->
@view.setIncludes([])
expect(@view._pages).toEqual({})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
describe "invalidate", ->
it "should clear the metadata cache for each page and re-fetch", ->
@view.invalidate({shallow: false})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
expect(@view._pages[0].metadata).toEqual({})
describe "when the shallow option is provided", ->
it "should refetch items in each page, but not flush the item metadata cache", ->
beforeMetadata = @view._pages[0].metadata
@view.invalidate({shallow: true})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
expect(@view._pages[0].metadata).toEqual(beforeMetadata)
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
describe "when the shallow option is provided with specific changed items", ->
it "should determine whether changes to these items make page(s) invalid", ->
spyOn(@view, 'invalidateAfterDatabaseChange').andCallFake ->
@view.invalidate({shallow: true, change: {objects: ['a'], type: 'persist'}})
expect(@view.invalidateAfterDatabaseChange).toHaveBeenCalled()
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
describe "invalidateMetadataFor", ->
it "should clear cached metadata for just the items whose ids are provided", ->
expect(@view._pages[0].metadata).toEqual({'a': 'a-metadata', 'b': 'b-metadata', 'c': 'c-metadata'})
expect(@view._pages[1].metadata).toEqual({'d': 'd-metadata', 'e': 'e-metadata', 'f': 'f-metadata'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
@view.invalidateMetadataFor(['b', 'e'])
expect(@view._pages[0].metadata['b']).toBe(undefined)
expect(@view._pages[1].metadata['e']).toBe(undefined)
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
it "should re-retrieve page metadata for only impacted pages", ->
spyOn(@view, 'retrievePageMetadata')
@view.invalidateMetadataFor(['e'])
expect(@view.retrievePageMetadata).toHaveBeenCalled()
expect(@view.retrievePageMetadata.calls[0].args[0]).toEqual('1')
describe "invalidateAfterDatabaseChange", ->
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
beforeEach ->
@inbox = new Label(id: 'l-1', name: 'inbox', displayName: 'Inbox')
@archive = new Label(id: 'l-2', name: 'archive', displayName: 'archive')
@a = new Thread(id: 'a', subject: 'a', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
@b = new Thread(id: 'b', subject: 'b', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
@c = new Thread(id: 'c', subject: 'c', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
@d = new Thread(id: 'd', subject: 'd', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
@e = new Thread(id: 'e', subject: 'e', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
@f = new Thread(id: 'f', subject: 'f', labels:[@inbox], lastMessageReceivedTimestamp: new Date(1428526885604))
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
@view = new DatabaseView Thread,
matchers: [Thread.attributes.labels.contains('l-1')]
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
@view._pages =
"0":
items: [@a, @b, @c]
metadata: {'a': 'a-metadata', 'b': 'b-metadata', 'c': 'c-metadata'}
loaded: true
"1":
items: [@d, @e, @f]
metadata: {'d': 'd-metadata', 'e': 'e-metadata', 'f': 'f-metadata'}
loaded: true
spyOn(@view, 'invalidateRetainedRange')
it "should invalidate the entire range if more than 5 items are provided", ->
@view.invalidateAfterDatabaseChange({objects:[@a, @b, @c, @d, @e, @f], type:'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
it "should invalidate the entire range if a provided item is in the set but no longer matches the set", ->
a = new Thread(@a)
a.labels = [@archive]
@view.invalidateAfterDatabaseChange({objects:[a], type:'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
it "should invalidate the entire range if a provided item is not in the set but matches the set", ->
incoming = new Thread(id: 'a', subject: 'a', labels:[@inbox], lastMessageReceivedTimestamp: new Date())
@view.invalidateAfterDatabaseChange({objects:[incoming], type:'persist'})
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
it "should invalidate the entire range if a provided item matches the set and the value of it's sorting attribute has changed", ->
a = new Thread(@a)
a.lastMessageReceivedTimestamp = new Date(1428526909533)
@view.invalidateAfterDatabaseChange({objects:[a], type:'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).toHaveBeenCalled()
it "should not do anything if no provided items are in the set or belong in the set", ->
archived = new Thread(id: 'zz', labels: [@archive])
@view.invalidateAfterDatabaseChange({objects:[archived], type: 'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).not.toHaveBeenCalled()
it "should replace items in place otherwise", ->
a = new Thread(@a)
a.subject = 'Subject changed, nothing to see here!'
@view.invalidateAfterDatabaseChange({objects:[a], type: 'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).not.toHaveBeenCalled()
a = new Thread(@a)
a.labels = [@inbox, @archive] # not realistic, but doesn't change membership in set
@view.invalidateAfterDatabaseChange({objects:[a], type: 'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view.invalidateRetainedRange).not.toHaveBeenCalled()
it "should attach the metadata field to replaced items", ->
spyOn(@view._emitter, 'emit')
subject = 'Subject changed, nothing to see here!'
runs ->
e = new Thread(@e)
e.subject = subject
@view.invalidateAfterDatabaseChange({objects:[e], type: 'persist'})
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[1].items[1].id).toEqual(@e.id)
expect(@view._pages[1].items[1].subject).toEqual(subject)
expect(@view._pages[1].items[1].metadata).toEqual(@view._pages[1].metadata[@e.id])
describe "when items have been removed", ->
beforeEach ->
spyOn(@view._emitter, 'emit')
@start = @view._pages[1].lastTouchTime
runs ->
b = new Thread(@b)
b.labels = []
@view.invalidateAfterDatabaseChange({objects:[b], type: 'persist'})
waitsFor ->
@view._emitter.emit.callCount > 0
it "should optimistically remove them and shift result pages", ->
expect(@view._pages[0].items).toEqual([@a, @c, @d])
expect(@view._pages[1].items).toEqual([@e, @f])
it "should change the lastTouchTime date of changed pages so that refreshes started before the replacement do not revert it's changes", ->
expect(@view._pages[0].lastTouchTime isnt @start).toEqual(true)
expect(@view._pages[1].lastTouchTime isnt @start).toEqual(true)
describe "when items have been unpersisted but still match criteria", ->
beforeEach ->
spyOn(@view._emitter, 'emit')
@start = @view._pages[1].lastTouchTime
runs ->
@view.invalidateAfterDatabaseChange({objects:[@b], type: 'unpersist'})
waitsFor ->
@view._emitter.emit.callCount > 0
it "should optimistically remove them and shift result pages", ->
expect(@view._pages[0].items).toEqual([@a, @c, @d])
expect(@view._pages[1].items).toEqual([@e, @f])
it "should change the lastTouchTime date of changed pages so that refreshes started before the replacement do not revert it's changes", ->
expect(@view._pages[0].lastTouchTime isnt @start).toEqual(true)
expect(@view._pages[1].lastTouchTime isnt @start).toEqual(true)
describe "cullPages", ->
beforeEach ->
@view._retainedRange = {start: 200, end: 399}
@view._pages = {}
for i in [0..9]
@view._pages[i] =
items: [new Thread(id: 'a'), new Thread(id: 'b'), new Thread(id: 'c')]
metadata: {'a': 'a-metadata', 'b': 'b-metadata', 'c': 'c-metadata'}
loaded: true
it "should not remove pages in the retained range", ->
@view.cullPages()
expect(@view._pages[2]).toBeDefined()
expect(@view._pages[3]).toBeDefined()
expect(@view._pages[4]).toBeDefined()
it "should remove pages far from the retained range", ->
@view.cullPages()
expect(@view._pages[7]).not.toBeDefined()
expect(@view._pages[8]).not.toBeDefined()
expect(@view._pages[9]).not.toBeDefined()
describe "retrievePage", ->
beforeEach ->
@config =
matchers: [Message.attributes.namespaceId.equal('asd')]
orders: [Message.attributes.date.descending()]
@view = new DatabaseView(Message, @config)
@queries = []
it "should initialize the page and set loading to true", ->
@view.retrievePage(0)
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
expect(@view._pages[0].metadata).toEqual({})
expect(@view._pages[0].items).toEqual([])
expect(@view._pages[0].loading).toEqual(true)
it "should make a database query for the correct item range", ->
@view.retrievePage(2)
expect(@queries.length).toBe(1)
expect(@queries[0]._range).toEqual({offset: @view._pageSize * 2, limit: @view._pageSize})
expect(@queries[0]._matchers).toEqual(@config.matchers)
it "should order results properly", ->
@view.retrievePage(2)
expect(@queries.length).toBe(1)
expect(@queries[0]._orders).toEqual(@config.orders)
describe "once the database request has completed", ->
beforeEach ->
@view.retrievePage(0)
@completeQuery = =>
@items = [new Thread(id: 'model-a'), new Thread(id: 'model-b'), new Thread(id: 'model-c')]
@queries[0].resolve(@items)
@queries = []
feat(thread-list): Multiple selection, bulk actions, refactoring Summary: This diff provides multi-selection in the thread list powered by a new ModelList component that implements selection on top of ListTabular (or soon another List component). It includes business logic for single selection, shift selection, command-click selection, etc. This diff also improves the performance of DatabaseView by assessing whether updates are required based on specific database changes and skipping queries in many scenarios. WIP WIP Move selection into modelView instead of store WIP Preparing to convert to ModelList mixin Make ThreadStore => ThreadListStore Break the DraftStore in two (new DraftListStore) to avoid keeping all drafts in all windows Get rid of unread instance variable in favor of getter that falls through to isUnread() Much smarter logic in DatabaseView to prevent needless queries (especially counts and full invalidation of retained range) Squashed commit of the following: commit 486516b540e659735675765ca8b20d8a107ee2a9 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:23 2015 -0700 Invalidate the retained range debounced commit 7ac80403f52d108696c555f79c4c687d969f0228 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:30:16 2015 -0700 Wait until after the view updates to move focus commit 88d66eb19a9710847ff98bea22045bb686f30cc6 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 17:28:01 2015 -0700 Bail out early when loading data if a reload has been requested commit a49bedc44687040f7c675ff298376917a0b5fdcb Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:58 2015 -0700 Log query data when in a query is being logged commit c64a9e02f9072fd30edb98c45be581d6ac00c48a Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:45 2015 -0700 Mark thread and messages as read in parallel instead of in sequence commit 4b227100a795e20257cda0d60b00cc75b0000b0f Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:38:32 2015 -0700 Don't load tags with hardcoded IDs from the database, and load them in parallel instead of in sequence commit aeb7f1d646786cfa1c247fe78ce5467da07c4446 Author: Ben Gotow <bengotow@gmail.com> Date: Tue Apr 7 16:37:54 2015 -0700 Pass objects instead of ids to thread methods—since we always have the most current thread anyway, this makes things a bit faster commit e70889d1d05ece81a081b8b3f27b62491429b6f9 Author: Ben Gotow <bengotow@gmail.com> Date: Mon Apr 6 16:41:49 2015 -0700 [icon] Paper airplanes Restyle account sidebar, optimize tag count queries a bit more Fix initialization issue with webkit image mask Can't compare dates with is/isnt Assets for check boxes Bug fixes Wrap ModelList instead of providing props Verbose mode for database view Fix existing specs Six new specs covering invalidateIfItemsInconsistent Test Plan: Run 40+ new tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1410
2015-04-09 10:25:00 +08:00
spyOn(@view, 'loaded').andCallFake -> true
spyOn(@view._emitter, 'emit')
it "should populate the page items and call trigger", ->
runs ->
@completeQuery()
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[0].items).toEqual(@items)
expect(@view._emitter.emit).toHaveBeenCalled()
it "should set loading to false for the page", ->
runs ->
expect(@view._pages[0].loading).toEqual(true)
@completeQuery()
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[0].loading).toEqual(false)
describe "if an item metadata provider is configured", ->
beforeEach ->
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
@view._metadataProvider = (ids) ->
results = {}
for id in ids
results[id] = "metadata-for-#{id}"
Promise.resolve(results)
it "should set .metadata of each item", ->
runs ->
@completeQuery()
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[0].items[0].metadata).toEqual('metadata-for-model-a')
expect(@view._pages[0].items[1].metadata).toEqual('metadata-for-model-b')
it "should cache the metadata on the page object", ->
runs ->
@completeQuery()
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[0].metadata).toEqual
'model-a': 'metadata-for-model-a'
'model-b': 'metadata-for-model-b'
'model-c': 'metadata-for-model-c'
it "should always wait for metadata promises to resolve", ->
@resolves = []
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
@view._metadataProvider = (ids) =>
new Promise (resolve, reject) =>
perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore Summary: Allow Database models to create indexes, but don't autocreate bad ones fix minor bug in error-reporter Fix index on message list to make thread list lookups use proper index Developer bar ignores state changes unless it's open DatabaseView now asks for metadata for a set of items rather than calling a function for every item. Promise.props was cute but we really needed to make a single database query for all message metadata. New "in" matcher so you can say `thread_id IN (1,2,3)` Add .scroll-region-content-inner which is larger than the viewport by 1 page size, and uses transform(0,0,0) trick ScrollRegion exposes `onScrollEnd` so listTabular, et al don't need to re-implement it with more timers. Also removing requestAnimationFrame which was causing us to request scrollTop when it was not ready, and caching the values of... ...clientHeight/scrollHeight while scrolling is in-flight Updating rendered content 10 rows at a time (RangeChunkSize) was a bad idea. Instead, add every row in a render: pass as it comes in (less work all the time vs more work intermittently). Also remove bad requestAnimationFrame, and prevent calls to... ...updateRangeState from triggering additional calls to updateRangeState by removing `componentDidUpdate => updateRangeState ` Turning off hover (pointer-events:none) is now standard in ScrollRegion Loading text in the scroll tooltip, instead of random date shown Handle query parse errors by catching error and throwing a better more explanatory error Replace "quick action" retina images with background images to make React render easier Replace hasTagId with a faster implementation which doesn't call functions and doesn't build a temporary array Print query durations when printing to console instead of only in metadata Remove headers from support from ListTabular, we'll never use it Making columns part of state was a good idea but changing the array causes the entire ListTabular to re-render. To avoid this, be smarter about updating columns. This logic could potentially go in `componentDidReceiveProps` too. Fix specs and add 6 more for new database store functionality Test Plan: Run 6 new specs. More in the works? Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1651
2015-06-18 11:12:48 +08:00
results = {}
for id in ids
results[id] = "metadata-for-#{id}"
@resolves.push -> resolve(results)
runs ->
@completeQuery()
expect(@view._pages[0].items).toEqual([])
expect(@view._pages[0].metadata).toEqual({})
expect(@view._emitter.emit).not.toHaveBeenCalled()
waitsFor ->
@resolves.length > 0
runs ->
for resolve,idx in @resolves
resolve()
waitsFor ->
@view._emitter.emit.callCount > 0
runs ->
expect(@view._pages[0].items[0].metadata).toEqual('metadata-for-model-a')
expect(@view._pages[0].items[1].metadata).toEqual('metadata-for-model-b')
expect(@view._emitter.emit).toHaveBeenCalled()