Skip to content

Commit

Permalink
fix: Fixed live location event register and added a option
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 21, 2022
1 parent 8e26a00 commit 08949a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/chat/events/registerLiveLocationUpdateEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import Debug from 'debug';

import { config } from '../../config';
import * as webpack from '../../webpack';
import {
ChatStore,
Expand Down Expand Up @@ -108,7 +109,8 @@ function registerLiveLocationUpdateEvent() {
* Start for all active chats
*/
ChatStore.once('collection_has_synced', () => {
ChatStore.forEach((chat) => {
const chats = ChatStore.models.slice(0, config.liveLocationLimit);
chats.forEach((chat) => {
LiveLocationStore.update(chat.id)
.then((liveLocation) => {
liveLocation.startViewingMap();
Expand Down
9 changes: 8 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* ```javascript
* // Global variable before injection
* WPPConfig = {
* deviceName: 'WPPConnect'
* deviceName: 'WPPConnect',
* liveLocationLimit: 10
* };
* ```
*/
Expand All @@ -31,10 +32,16 @@ export interface Config {
* @default 'WPPConnect'
*/
deviceName: string | false;

/**
* Number of last chats to check live location after a page reload
*/
liveLocationLimit: number;
}

export const defaultConfig: Config = {
deviceName: false,
liveLocationLimit: 10,
};

export const config: Config = defaultConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/status/events/registerSyncedEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as webpack from '../../webpack';
import { StatusV3Store } from '../../whatsapp';
import { eventEmitter } from '../eventEmitter';

const debug = Debug('WA-JS:blocklist');
const debug = Debug('WA-JS:status');

webpack.onInjected(() => registerSyncedEvent());

Expand Down

0 comments on commit 08949a9

Please sign in to comment.