@ember-data/model 4.6.0 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,8 +56,8 @@ export default class BelongsToReference {
|
|
|
56
56
|
declare store: Store;
|
|
57
57
|
|
|
58
58
|
// unsubscribe tokens given to us by the notification manager
|
|
59
|
-
#token!:
|
|
60
|
-
#relatedToken:
|
|
59
|
+
#token!: object;
|
|
60
|
+
#relatedToken: object | null = null;
|
|
61
61
|
|
|
62
62
|
@tracked _ref = 0;
|
|
63
63
|
|
|
@@ -89,8 +89,10 @@ export default class BelongsToReference {
|
|
|
89
89
|
// TODO @feature we need the notification manager often enough
|
|
90
90
|
// we should potentially just expose it fully public
|
|
91
91
|
this.store._notificationManager.unsubscribe(this.#token);
|
|
92
|
+
this.#token = null as unknown as object;
|
|
92
93
|
if (this.#relatedToken) {
|
|
93
94
|
this.store._notificationManager.unsubscribe(this.#relatedToken);
|
|
95
|
+
this.#relatedToken = null;
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -100,6 +102,7 @@ export default class BelongsToReference {
|
|
|
100
102
|
this._ref; // consume the tracked prop
|
|
101
103
|
if (this.#relatedToken) {
|
|
102
104
|
this.store._notificationManager.unsubscribe(this.#relatedToken);
|
|
105
|
+
this.#relatedToken = null;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
let resource = this._resource();
|
|
@@ -104,29 +104,37 @@ export default class HasManyReference {
|
|
|
104
104
|
|
|
105
105
|
let resource = this._resource();
|
|
106
106
|
|
|
107
|
-
this.#relatedTokenMap
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
this.#relatedTokenMap.clear();
|
|
107
|
+
let map = this.#relatedTokenMap;
|
|
108
|
+
this.#relatedTokenMap = new Map();
|
|
111
109
|
|
|
112
110
|
if (resource && resource.data) {
|
|
113
111
|
return resource.data.map((resourceIdentifier) => {
|
|
114
112
|
const identifier = this.store.identifierCache.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
let token = map.get(identifier);
|
|
114
|
+
|
|
115
|
+
if (token) {
|
|
116
|
+
map.delete(identifier);
|
|
117
|
+
} else {
|
|
118
|
+
token = this.store._notificationManager.subscribe(
|
|
119
|
+
identifier,
|
|
120
|
+
(_: StableRecordIdentifier, bucket: NotificationType, notifiedKey?: string) => {
|
|
121
|
+
if (bucket === 'identity' || (bucket === 'attributes' && notifiedKey === 'id')) {
|
|
122
|
+
this._ref++;
|
|
123
|
+
}
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
);
|
|
126
|
+
}
|
|
124
127
|
this.#relatedTokenMap.set(identifier, token);
|
|
125
128
|
|
|
126
129
|
return identifier;
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
map.forEach((token) => {
|
|
134
|
+
this.store._notificationManager.unsubscribe(token);
|
|
135
|
+
});
|
|
136
|
+
map.clear();
|
|
137
|
+
|
|
130
138
|
return [];
|
|
131
139
|
}
|
|
132
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/model",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
4
4
|
"description": "The default blueprint for ember-cli addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"test:node": "mocha"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ember-data/canary-features": "4.6.
|
|
22
|
-
"@ember-data/private-build-infra": "4.6.
|
|
23
|
-
"@ember-data/store": "4.6.
|
|
21
|
+
"@ember-data/canary-features": "4.6.2",
|
|
22
|
+
"@ember-data/private-build-infra": "4.6.2",
|
|
23
|
+
"@ember-data/store": "4.6.2",
|
|
24
24
|
"@ember/edition-utils": "^1.2.0",
|
|
25
25
|
"@ember/string": "^3.0.0",
|
|
26
26
|
"@embroider/macros": "^1.8.3",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"inflection": "~1.13.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ember-data/unpublished-test-infra": "4.6.
|
|
37
|
+
"@ember-data/unpublished-test-infra": "4.6.2",
|
|
38
38
|
"@ember/optional-features": "^2.0.0",
|
|
39
39
|
"@ember/test-helpers": "~2.7.0",
|
|
40
40
|
"broccoli-asset-rev": "^3.0.0",
|
|
@@ -61,8 +61,7 @@
|
|
|
61
61
|
"webpack": "^5.74.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
|
-
"node": "^14.8.0 || 16.* || >= 18.*"
|
|
65
|
-
"yarn": "1.22.19"
|
|
64
|
+
"node": "^14.8.0 || 16.* || >= 18.*"
|
|
66
65
|
},
|
|
67
66
|
"ember-addon": {
|
|
68
67
|
"configPath": "tests/dummy/config"
|