MCPcopy Create free account
hub / github.com/apitable/apitable / handleSubscriptions

Method handleSubscriptions

packages/core/src/engine/engine.ts:219–249  ·  view source on GitHub ↗

* Member remote changeset update record subscriptions * @param remoteChangeset

(remoteChangeset: IRemoteChangeset)

Source from the content-addressed store, hash-verified

217 * @param remoteChangeset
218 */
219 handleSubscriptions(remoteChangeset: IRemoteChangeset) {
220 let hasCreatedFieldWithSubscription = false;
221 let otherCmdTriggerSubscription = false;
222
223 const fieldMap = getFieldMap(this.getState(), this.resourceId);
224 remoteChangeset.operations.forEach(op => {
225 // AddRecords
226 if (op.cmd === CollaCommandName.AddRecords) {
227 if (fieldMap && Object.values(fieldMap).some(field => field.type === FieldType.CreatedBy && field.property.subscription)) {
228 hasCreatedFieldWithSubscription = true;
229 return;
230 }
231 } else {
232 // other command
233 op.actions.map(action => {
234 const path = testPath(action.p, ['recordMap', ':recordId', 'data', ':fieldId']);
235 if (path.pass) {
236 const field = fieldMap?.[path.fieldId];
237 if (field?.type === FieldType.Member && Boolean(field.property.subscription)) {
238 otherCmdTriggerSubscription = true;
239 return;
240 }
241 }
242 });
243 }
244 });
245
246 if (hasCreatedFieldWithSubscription || otherCmdTriggerSubscription) {
247 this.dispatch(getSubscriptionsAction(this.resourceId));
248 }
249 }
250
251 /**
252 * The submitted changeset is accepted by the service

Callers 1

handleAcceptCommitMethod · 0.95

Calls 5

testPathFunction · 0.90
getSubscriptionsActionFunction · 0.90
forEachMethod · 0.45
mapMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected