diff --git a/app/components/gh-psm-authors-input.js b/app/components/gh-psm-authors-input.js index a32173004..092ad71e4 100644 --- a/app/components/gh-psm-authors-input.js +++ b/app/components/gh-psm-authors-input.js @@ -11,18 +11,25 @@ export default Component.extend({ tagName: '', triggerId: '', + // internal attrs + availableAuthors: null, + // closure actions updateAuthors() {}, - // live-query of all users for author input autocomplete - availableAuthors: computed(function () { - return this.get('store').filter('user', {limit: 'all'}, () => true); - }), - availableAuthorNames: computed('availableAuthors.@each.name', function () { return this.get('availableAuthors').map(author => author.get('name').toLowerCase()); }), + init() { + this._super(...arguments); + // perform a background query to fetch all users and set `availableAuthors` + // to a live-query that will be immediately populated with what's in the + // store and be updated when the above query returns + this.store.query('user', {limit: 'all'}); + this.set('availableAuthors', this.store.peekAll('user')); + }, + actions: { updateAuthors(newAuthors) { this.updateAuthors(newAuthors); diff --git a/app/components/gh-psm-tags-input.js b/app/components/gh-psm-tags-input.js index a1d4aeef0..5fdf17a3d 100644 --- a/app/components/gh-psm-tags-input.js +++ b/app/components/gh-psm-tags-input.js @@ -10,15 +10,22 @@ export default Component.extend({ post: null, tagName: '', - // live-query of all tags for tag input autocomplete - availableTags: computed(function () { - return this.get('store').filter('tag', {limit: 'all'}, () => true); - }), + // internal attrs + availableTags: null, availableTagNames: computed('availableTags.@each.name', function () { return this.get('availableTags').map(tag => tag.get('name').toLowerCase()); }), + init() { + this._super(...arguments); + // perform a background query to fetch all users and set `availableTags` + // to a live-query that will be immediately populated with what's in the + // store and be updated when the above query returns + this.store.query('tag', {limit: 'all'}); + this.set('availableTags', this.store.peekAll('tag')); + }, + actions: { matchTags(tagName, term) { return tagName.toLowerCase() === term.trim().toLowerCase(); diff --git a/app/controllers/settings/tags.js b/app/controllers/settings/tags.js index 2c8486e74..9d7d80996 100644 --- a/app/controllers/settings/tags.js +++ b/app/controllers/settings/tags.js @@ -1,5 +1,6 @@ import Controller, {inject as controller} from '@ember/controller'; import {alias, equal, sort} from '@ember/object/computed'; +import {computed} from '@ember/object'; import {run} from '@ember/runloop'; export default Controller.extend({ @@ -12,8 +13,12 @@ export default Controller.extend({ tagListFocused: equal('keyboardFocus', 'tagList'), tagContentFocused: equal('keyboardFocus', 'tagContent'), + filteredTags: computed('tags.@each.isNew', function () { + return this.get('tags').filterBy('isNew', false); + }), + // TODO: replace with ordering by page count once supported by the API - sortedTags: sort('tags', function (a, b) { + sortedTags: sort('filteredTags', function (a, b) { let idA = +a.get('id'); let idB = +b.get('id'); diff --git a/app/controllers/team/index.js b/app/controllers/team/index.js index f5e3030de..e7426207f 100644 --- a/app/controllers/team/index.js +++ b/app/controllers/team/index.js @@ -1,5 +1,6 @@ /* eslint-disable ghost/ember/alias-model-in-controller */ import Controller from '@ember/controller'; +import {computed} from '@ember/object'; import {inject as service} from '@ember/service'; import {sort} from '@ember/object/computed'; @@ -21,10 +22,14 @@ export default Controller.extend({ this.userOrder = ['name', 'email']; }, - sortedInvites: sort('invites', 'inviteOrder'), + sortedInvites: sort('filteredInvites', 'inviteOrder'), sortedActiveUsers: sort('activeUsers', 'userOrder'), sortedSuspendedUsers: sort('suspendedUsers', 'userOrder'), + filteredInvites: computed('invites.@each.isNew', function () { + return this.get('invites').filterBy('isNew', false); + }), + actions: { toggleInviteUserModal() { this.toggleProperty('showInviteUserModal'); diff --git a/app/routes/settings/tags.js b/app/routes/settings/tags.js index a392285c6..a7634da3e 100644 --- a/app/routes/settings/tags.js +++ b/app/routes/settings/tags.js @@ -34,12 +34,12 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, ShortcutsRoute, { // pausing to show the loading spinner if no tags have been loaded yet model() { let promise = this.store.query('tag', {limit: 'all', include: 'count.posts'}); - let filter = this.store.filter('tag', tag => !tag.get('isNew')); + let tags = this.store.peekAll('tag'); if (this.store.peekAll('tag').get('length') === 0) { - return promise.then(() => filter); + return promise.then(() => tags); } else { - return filter; + return tags; } }, diff --git a/app/routes/team/index.js b/app/routes/team/index.js index 4d704f043..2b21aaa5c 100644 --- a/app/routes/team/index.js +++ b/app/routes/team/index.js @@ -31,7 +31,7 @@ export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, Infinit // authors do not have permission to hit the invites or suspended users endpoint if (!user.get('isAuthorOrContributor')) { modelPromises.invites = this.store.query('invite', {limit: 'all'}) - .then(() => this.store.filter('invite', invite => !invite.get('isNew'))); + .then(() => this.store.peekAll('invite')); // fetch suspended users separately so that infinite scroll still works modelPromises.suspendedUsers = this.store.query('user', {limit: 'all', filter: 'status:inactive'}); diff --git a/package.json b/package.json index 6b13b524f..011163b04 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "ember-composable-helpers": "2.1.0", "ember-concurrency": "0.8.17", "ember-data": "3.1.1", - "ember-data-filter": "1.13.0", "ember-drag-drop": "0.4.7", "ember-element-resize-detector": "0.1.5", "ember-export-application-global": "2.0.0", diff --git a/yarn.lock b/yarn.lock index 6071d9d52..a64fd7e85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3333,7 +3333,7 @@ ember-cli-babel@6.12.0, ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.10, ember-cli-version-checker "^2.1.0" semver "^5.4.1" -ember-cli-babel@^5.0.0, ember-cli-babel@^5.1.5, ember-cli-babel@^5.1.6, ember-cli-babel@^5.1.7, ember-cli-babel@^5.2.4: +ember-cli-babel@^5.1.5, ember-cli-babel@^5.1.6, ember-cli-babel@^5.1.7, ember-cli-babel@^5.2.4: version "5.2.8" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-5.2.8.tgz#0356b03cc3fdff5d0f2ecaa46a0e1cfaebffd876" dependencies: @@ -3824,12 +3824,6 @@ ember-cookies@^0.3.0: ember-cli-babel "^6.8.2" ember-getowner-polyfill "^1.1.0 || ^2.0.0" -ember-data-filter@1.13.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/ember-data-filter/-/ember-data-filter-1.13.0.tgz#54f9d54706d8ff61e9f0522660c86ec8de34def1" - dependencies: - ember-cli-babel "^5.0.0" - ember-data@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.1.1.tgz#8c17c97a4932b0a0a405cc3e38c43140880366d2"