diff --git a/src/chat/events/registerLiveLocationUpdateEvent.ts b/src/chat/events/registerLiveLocationUpdateEvent.ts index 5832d8c73e..2e69eff915 100644 --- a/src/chat/events/registerLiveLocationUpdateEvent.ts +++ b/src/chat/events/registerLiveLocationUpdateEvent.ts @@ -16,6 +16,7 @@ import Debug from 'debug'; +import { config } from '../../config'; import * as webpack from '../../webpack'; import { ChatStore, @@ -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(); diff --git a/src/config.ts b/src/config.ts index bd5c1d6d52..a2d2637777 100644 --- a/src/config.ts +++ b/src/config.ts @@ -21,7 +21,8 @@ * ```javascript * // Global variable before injection * WPPConfig = { - * deviceName: 'WPPConnect' + * deviceName: 'WPPConnect', + * liveLocationLimit: 10 * }; * ``` */ @@ -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; diff --git a/src/status/events/registerSyncedEvent.ts b/src/status/events/registerSyncedEvent.ts index f182fe0c9b..0a827e95cb 100644 --- a/src/status/events/registerSyncedEvent.ts +++ b/src/status/events/registerSyncedEvent.ts @@ -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());