Skip to content

Commit

Permalink
fix: Dropped support for live location events for WhatsApp >= 2.2301.5
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 10, 2023
1 parent 69e5db5 commit d87367b
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 224 deletions.
4 changes: 3 additions & 1 deletion src/whatsapp/collections/GroupMetadataCollection.ts
Expand Up @@ -28,5 +28,7 @@ export declare class GroupMetadataCollection extends BaseCollection<GroupMetadat
exportModule(
exports,
{ GroupMetadataCollection: 'default.constructor' },
(m) => typeof m.default.onParentGroupChange === 'function'
(m) =>
typeof m.default.onParentGroupChange === 'function' || // @whatsapp < 2.2301.5
typeof m.default._handleParentGroupChange === 'function' // @whatsapp >= 2.2301.5
);
20 changes: 20 additions & 0 deletions src/whatsapp/collections/LiveLocationCollection.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as webpack from '../../webpack';
import { exportModule } from '../exportModule';
import { LiveLocationModel } from '../models';
import { BaseCollection } from '.';
Expand All @@ -36,3 +37,22 @@ exportModule(
},
(m) => m.LiveLocationCollectionImpl
);

const fallback = {};
let cache: any = null;

// Lazy load
Object.defineProperty(fallback, 'LiveLocationCollectionImpl', {
configurable: true,
enumerable: true,
get() {
if (!cache) {
class LiveLocationCollection extends BaseCollection<any, any> {}
LiveLocationCollection.model = LiveLocationModel;
cache = LiveLocationCollection;
}
return cache;
},
});

webpack.injectFallbackModule('LiveLocationCollection', fallback);
163 changes: 0 additions & 163 deletions src/whatsapp/misc/Features.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/whatsapp/misc/index.ts
Expand Up @@ -21,7 +21,6 @@ export * from './Cmd';
export * from './Conn';
export * from './Constants';
export * from './EventEmitter';
export * from './Features';
export * from './ImageUtils';
export * from './Locale';
export * from './MediaBlobCache';
Expand Down
20 changes: 20 additions & 0 deletions src/whatsapp/models/LiveLocationModel.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as webpack from '../../webpack';
import { LiveLocationCollection, ParticipantCollection } from '../collections';
import { exportProxyModel } from '../exportModule';
import { Wid } from '../misc';
Expand Down Expand Up @@ -60,3 +61,22 @@ export declare class LiveLocationModel extends Model<LiveLocationCollection> {
}

exportProxyModel(exports, 'LiveLocationModel');

const fallback = {};
let cache: any = null;

// Lazy load
Object.defineProperty(fallback, 'LiveLocationModel', {
configurable: true,
enumerable: true,
get() {
if (!cache) {
class LiveLocationModel extends Model {}
LiveLocationModel.prototype.proxyName = 'live-location';
cache = LiveLocationModel;
}
return cache;
},
});

webpack.injectFallbackModule('LiveLocationModel', fallback);
21 changes: 21 additions & 0 deletions src/whatsapp/models/LiveLocationParticipantModel.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as webpack from '../../webpack';
import { exportProxyModel } from '../exportModule';
import { Wid } from '../misc';
import {
Expand Down Expand Up @@ -70,3 +71,23 @@ export declare class LiveLocationParticipantModel extends Model {
}

exportProxyModel(exports, 'LiveLocationParticipantModel');

const fallback = {};
let cache: any = null;

// Lazy load
Object.defineProperty(fallback, 'LiveLocationParticipantModel', {
configurable: true,
enumerable: true,
get() {
if (!cache) {
class LiveLocationParticipantModel extends Model {}
LiveLocationParticipantModel.prototype.proxyName =
'live-location-participant';
cache = LiveLocationParticipantModel;
}
return cache;
},
});

webpack.injectFallbackModule('LiveLocationParticipantModel', fallback);
58 changes: 0 additions & 58 deletions src/whatsapp/models/WebCallModel.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/whatsapp/models/index.ts
Expand Up @@ -69,4 +69,3 @@ export * from './StickerPackModel';
export * from './StreamModel';
export * from './TemplateButtonModel';
export * from './UnreadMentionModel';
export * from './WebCallModel';
19 changes: 19 additions & 0 deletions src/whatsapp/stores.ts
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

import * as webpack from '../webpack';
import * as collections from './collections';
import { LiveLocationCollection } from './collections';
import { exportModule } from './exportModule';

/** @whatsapp 32826
Expand Down Expand Up @@ -202,3 +204,20 @@ exportModule(
},
(m) => m.StickerPackCollection
);

const fallback = {};
let cache: any = null;

// Lazy load
Object.defineProperty(fallback, 'LiveLocationCollection', {
configurable: true,
enumerable: true,
get() {
if (!cache) {
cache = new LiveLocationCollection();
}
return cache;
},
});

webpack.injectFallbackModule('LiveLocationStore', fallback);

0 comments on commit d87367b

Please sign in to comment.