Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] ports fix for infinite-relationship-retry from #5492 #5499

Merged
merged 2 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
ecmaVersion: 6,
sourceType: 'module',
},
parser: 'babel-eslint',
extends: 'eslint:recommended',
env: {
'browser': true,
Expand Down Expand Up @@ -41,7 +42,7 @@ module.exports = {
'curly': ['error', 'all'],
'eol-last': 'error',
'no-trailing-spaces': 'error',
'comma-dangle': ['error', 'never'],
'comma-dangle': ['off', 'never'],
'space-before-blocks': ['error', 'always'],
'indent': ['error', 2, {
'SwitchCase': 1,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tmp/
tests/source/
dist/
*.iml
yarn-error.log

benchmarks/results/*.json

Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
sudo: false
dist: trusty
node_js:
- "4"
- "6"

addons:
chrome: stable
Expand Down Expand Up @@ -56,8 +56,8 @@ jobs:

# runs tests against each supported Ember version
- stage: older version tests
env: EMBER_TRY_SCENARIO=ember-lts-2.12
- env: EMBER_TRY_SCENARIO=ember-lts-2.16
env: EMBER_TRY_SCENARIO=ember-lts-2.16
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
Expand Down
2 changes: 1 addition & 1 deletion addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default EmberObject.extend(MutableArray, Evented, {

@property {Boolean} isLoaded
*/
this.isLoaded = false;
this.isLoaded = this.isLoaded || false;
this.length = 0;

/**
Expand Down
12 changes: 6 additions & 6 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default class InternalModel {

this.store = store;
this.modelName = modelName;
this._loadingPromise = null;
this._promiseProxy = null;
this._record = null;
this._isDestroyed = false;
this.isError = false;
Expand Down Expand Up @@ -538,11 +538,11 @@ export default class InternalModel {
this.dematerializeRecord();

if (this._scheduledDestroy === null) {
// TODO: use run.schedule once we drop 1.13
if (!run.currentRunLoop) {
assert('You have turned on testing mode, which disabled the run-loop\'s autorun.\n You will need to wrap any code with asynchronous side-effects in a run', Ember.testing);
}
this._scheduledDestroy = run.backburner.schedule('destroy', this, '_checkForOrphanedInternalModels')
this._scheduledDestroy = run.backburner.schedule(
'destroy',
this,
'_checkForOrphanedInternalModels'
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions addon/-private/system/model/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ const RootState = {

// EVENTS
loadingData(internalModel, promise) {
internalModel._loadingPromise = promise;
internalModel._promiseProxy = promise;
internalModel.transitionTo('loading');
},

Expand All @@ -522,7 +522,7 @@ const RootState = {
isLoading: true,

exit(internalModel) {
internalModel._loadingPromise = null;
internalModel._promiseProxy = null;
},

// EVENTS
Expand Down
4 changes: 3 additions & 1 deletion addon/-private/system/record-array-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

import { A } from '@ember/array';
import { set, get } from '@ember/object';
import { run as emberRun } from '@ember/runloop';
import { run as emberRunloop } from '@ember/runloop';
import { assert } from '@ember/debug';
import cloneNull from './clone-null';
import {
RecordArray,
AdapterPopulatedRecordArray
} from './record-arrays';

const emberRun = emberRunloop.backburner;

const {
_flush,
array_remove,
Expand Down
12 changes: 7 additions & 5 deletions addon/-private/system/references/belongs-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,17 @@ export default class BelongsToReference extends Reference {
@return {Promise} a promise that resolves with the record in this belongs-to relationship.
*/
load() {
if (this.remoteType() === "id") {
return this.belongsToRelationship.getRecord();
}
let rel = this.belongsToRelationship;

rel.getData();

if (this.remoteType() === "link") {
return this.belongsToRelationship.findLink().then((internalModel) => {
if (rel.fetchPromise !== null) {
return rel.fetchPromise.then(() => {
return this.value();
});
}

return resolve(this.value());
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/-private/system/references/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ export default class HasManyReference extends Reference {
this has-many relationship.
*/
load() {
// TODO this can be simplified
if (!this._isLoaded()) {
return this.hasManyRelationship.getRecords();
return this.hasManyRelationship.getData();
}

return resolve(this.hasManyRelationship.manyArray);
Expand Down
6 changes: 3 additions & 3 deletions addon/-private/system/relationships/belongs-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export default function belongsTo(modelName, options) {
});
}

return this._internalModel._relationships.get(key).getRecord();
return this._internalModel._relationships.get(key).getData();
},
set(key, value) {
this._internalModel.setDirtyBelongsTo(key, value);

return this._internalModel._relationships.get(key).getRecord();
}
return this._internalModel._relationships.get(key).getData();
},
}).meta(meta);
}
6 changes: 3 additions & 3 deletions addon/-private/system/relationships/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export default function hasMany(type, options) {

return computed({
get(key) {
return this._internalModel._relationships.get(key).getRecords();
return this._internalModel._relationships.get(key).getData();
},
set(key, records) {
this._internalModel.setDirtyHasMany(key, records);

return this._internalModel._relationships.get(key).getRecords();
}
return this._internalModel._relationships.get(key).getData();
},
}).meta(meta);
}
Loading