Skip to content

Commit 000547e

Browse files
gitKrystanMehulKChaudhari
authored andcommitted
Don't set isDirty to true in diff callbacks (emberjs#9765)
* More overnotification fixes * Fix DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE case
1 parent 20ae56d commit 000547e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/graph/src/-private/operations/replace-related-records.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ function replaceRelatedRecordsRemote(graph: Graph, op: ReplaceRelatedRecordsOper
226226
);
227227
}
228228
}
229-
relationship.isDirty = true;
230229
}
231230
addToInverse(graph, identifier, definition.inverseKey, op.record, isRemote);
232231
},
@@ -245,7 +244,6 @@ function replaceRelatedRecordsRemote(graph: Graph, op: ReplaceRelatedRecordsOper
245244
);
246245
}
247246
}
248-
relationship.isDirty = true;
249247
}
250248
removeFromInverse(graph, identifier, definition.inverseKey, op.record, isRemote);
251249
}
@@ -273,7 +271,8 @@ function replaceRelatedRecordsRemote(graph: Graph, op: ReplaceRelatedRecordsOper
273271
// because we want to clear local changes even if
274272
// no change has occurred to preserve the legacy behavior
275273
relationship.definition.kind === 'hasMany' &&
276-
relationship.definition.resetOnRemoteUpdate !== false
274+
relationship.definition.resetOnRemoteUpdate !== false &&
275+
(diff.changed || wasDirty)
277276
) {
278277
const deprecationInfo: {
279278
removals: StableRecordIdentifier[];

tests/ember-data__graph/tests/integration/graph/diff-preservation-test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ module('Integration | Graph | Diff Preservation', function (hooks) {
747747
class App extends Model {
748748
@attr declare name: string;
749749
@hasMany('config', { async: false, inverse: 'app' }) declare configs: Config[];
750-
@hasMany('namespace', { async: false, inverse: 'apps' }) declare namespaces: Namespace | null;
750+
@hasMany('namespace', { async: false, inverse: 'apps' }) declare namespaces: Namespace[];
751751
}
752752

753753
class Namespace extends Model {
@@ -777,7 +777,7 @@ module('Integration | Graph | Diff Preservation', function (hooks) {
777777
// each namespace has the app and 2 more apps
778778
store._join(() => {
779779
// setup primary app relationships
780-
// this also convers the belongsTo side on config
780+
// this also converts the belongsTo side on config
781781
graph.push({
782782
op: 'updateRelationship',
783783
field: 'configs',
@@ -842,7 +842,7 @@ module('Integration | Graph | Diff Preservation', function (hooks) {
842842
// for app:1
843843
store._join(() => {
844844
// setup primary app relationships
845-
// this also convers the belongsTo side on config
845+
// this also converts the belongsTo side on config
846846
graph.push({
847847
op: 'updateRelationship',
848848
field: 'configs',

tests/ember-data__graph/tests/test-helper.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Application from 'ember-data__graph/app';
44
import config from 'ember-data__graph/config/environment';
55

66
import configureAsserts from '@ember-data/unpublished-test-infra/test-support/asserts/index';
7+
import { IS_CI } from '@warp-drive/build-config/env';
78
import { setupGlobalHooks } from '@warp-drive/diagnostic';
89
import { configure } from '@warp-drive/diagnostic/ember';
910
import { start } from '@warp-drive/diagnostic/runners/dom';
@@ -17,9 +18,9 @@ configure();
1718
setApplication(Application.create(config.APP));
1819
void start({
1920
tryCatch: false,
20-
debug: false,
21+
debug: IS_CI ? false : true,
2122
groupLogs: false,
2223
instrument: true,
23-
hideReport: true,
24+
hideReport: IS_CI ? true : false,
2425
useDiagnostic: true,
2526
});

0 commit comments

Comments
 (0)