Skip to content

Commit

Permalink
feat: Added WPP.conn.getHistorySyncProgress function
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Dec 6, 2022
1 parent 6840878 commit 9a47ef6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
44 changes: 44 additions & 0 deletions src/conn/functions/getHistorySyncProgress.ts
@@ -0,0 +1,44 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as wa_functions from '../../whatsapp/functions';

export interface HistorySyncProgress {
progress: number | null;
paused: boolean;
inProgress: boolean;
}

/**
* Return the current state of syncing old messages progress
*
* @example
* ```javascript
* const info = WPP.conn.getHistorySyncProgress();
* console.log(info.progress); // Output: 50
* console.log(info.paused); // Output: false0
* console.log(info.inProgress); // Output: true
* ```
*/
export function getHistorySyncProgress(): HistorySyncProgress {
const info = wa_functions.getHistorySyncProgress();

return {
progress: info.progress,
paused: info.paused || false,
inProgress: info.inProgress || false,
};
}
4 changes: 4 additions & 0 deletions src/conn/functions/index.ts
Expand Up @@ -15,6 +15,10 @@
*/

export { getAuthCode } from './getAuthCode';
export {
getHistorySyncProgress,
HistorySyncProgress,
} from './getHistorySyncProgress';
export { getMyDeviceId } from './getMyDeviceId';
export { getMyUserId } from './getMyUserId';
export { getPlatform } from './getPlatform';
Expand Down
3 changes: 2 additions & 1 deletion src/whatsapp/functions/getHistorySyncProgress.ts
Expand Up @@ -15,11 +15,12 @@
*/

import { exportModule } from '../exportModule';
import { HistorySyncProgressModel } from '../models';

/**
* @whatsapp 649959 >= 2.2244.5
*/
export declare function getHistorySyncProgress(): any;
export declare function getHistorySyncProgress(): HistorySyncProgressModel;

exportModule(
exports,
Expand Down

0 comments on commit 9a47ef6

Please sign in to comment.