Skip to content

Commit

Permalink
change to watch
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed Jan 16, 2023
1 parent 429e411 commit 0ae3b3d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe('ParseLiveQuery', function () {
startLiveQueryServer: true,
});
const query = new Parse.Query('Test');
query.listen('yolo');
query.watch('yolo');
const subscription = await query.subscribe();
const spy = {
create(obj) {
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ describe('ParseLiveQueryServer', function () {
done();
});

it('can handle create command with listen', async () => {
it('can handle create command with watch', async () => {
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
const parseLiveQueryServer = new ParseLiveQueryServer({});
Expand All @@ -1110,7 +1110,7 @@ describe('ParseLiveQueryServer', function () {
where: {
key: 'value',
},
listen: ['yolo'],
watch: ['yolo'],
};
await addMockSubscription(parseLiveQueryServer, clientId, requestId, parseWebSocket, query);
// Mock _matchesSubscription to return matching
Expand Down
16 changes: 8 additions & 8 deletions src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ class ParseLiveQueryServer {
} else {
return null;
}
const listenFieldsChanged = this._checkListenFields(client, requestId, message);
if (!listenFieldsChanged && (type === 'update' || type === 'create')) {
const watchFieldsChanged = this._checkWatchFields(client, requestId, message);
if (!watchFieldsChanged && (type === 'update' || type === 'create')) {
return;
}
res = {
Expand Down Expand Up @@ -712,15 +712,15 @@ class ParseLiveQueryServer {
return auth;
}

_checkListenFields(client: any, requestId: any, message: any) {
_checkWatchFields(client: any, requestId: any, message: any) {
const subscriptionInfo = client.getSubscriptionInfo(requestId);
const listen = subscriptionInfo?.listen;
if (!listen) {
const watch = subscriptionInfo?.watch;
if (!watch) {
return true;
}
const object = message.currentParseObject;
const original = message.originalParseObject;
return listen.some(field => !isDeepStrictEqual(object.get(field), original?.get(field)));
return watch.some(field => !isDeepStrictEqual(object.get(field), original?.get(field)));
}

async _matchesACL(acl: any, client: any, requestId: number): Promise<boolean> {
Expand Down Expand Up @@ -904,8 +904,8 @@ class ParseLiveQueryServer {
if (request.query.fields) {
subscriptionInfo.fields = request.query.fields;
}
if (request.query.listen) {
subscriptionInfo.listen = request.query.listen;
if (request.query.watch) {
subscriptionInfo.watch = request.query.watch;
}
if (request.sessionToken) {
subscriptionInfo.sessionToken = request.sessionToken;
Expand Down

0 comments on commit 0ae3b3d

Please sign in to comment.