Skip to content

Commit

Permalink
Add a fairly temporary shouldReconcile method
Browse files Browse the repository at this point in the history
  • Loading branch information
John Cowen authored and kaxcode committed May 29, 2020
1 parent 6557629 commit 7d32e21
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions ui-v2/app/adapters/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default Adapter.extend({
`;
} else {
return request`
GET /v1/internal/ui/services?${{ dc }}
GET /v1/internal/ui/services?${{ dc }}
${{
...this.formatNspace(ns),
index,
}}
${{
...this.formatNspace(ns),
index,
}}
`;
}
},
Expand Down
2 changes: 1 addition & 1 deletion ui-v2/app/services/data-source/protocols/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default Service.extend({
// always be complete, they should never have things like '///model'
let find;
const repo = this[model];
if (typeof repo.reconcile === 'function') {
if (repo.shouldReconcile(src)) {
configuration.createEvent = function(result = {}, configuration) {
const event = {
type: 'message',
Expand Down
3 changes: 3 additions & 0 deletions ui-v2/app/services/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default Service.extend({
},
//
store: service('store'),
shouldReconcile: function(method) {
return true;
},
reconcile: function(meta = {}) {
// unload anything older than our current sync date/time
if (typeof meta.date !== 'undefined') {
Expand Down
7 changes: 7 additions & 0 deletions ui-v2/app/services/repository/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ export default RepositoryService.extend({
getModelName: function() {
return modelName;
},
shouldReconcile: function(method) {
switch (method) {
case 'findGatewayBySlug':
return false;
}
return this._super(...arguments);
},
findBySlug: function(slug, dc) {
return this._super(...arguments).then(function(item) {
// TODO: Move this to the Serializer
Expand Down
6 changes: 2 additions & 4 deletions ui-v2/app/services/repository/type/event-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ const createProxy = function(repo, find, settings, cache, serialize = JSON.strin
const client = this.client;
// custom createEvent, here used to reconcile the ember-data store for each tick
let createEvent;
if (typeof repo.reconcile === 'function') {
if (repo.shouldReconcile(find)) {
createEvent = function(result = {}, configuration) {
const event = {
type: 'message',
data: result,
};
if (repo.reconcile === 'function') {
repo.reconcile(get(event, 'data.meta'));
}
repo.reconcile(get(event, 'data.meta'));
return event;
};
}
Expand Down

0 comments on commit 7d32e21

Please sign in to comment.