From 02ee36d6a108f68d9fa505b41e3bb33b96a1ef20 Mon Sep 17 00:00:00 2001 From: Edgard Date: Tue, 15 Nov 2022 20:33:40 -0300 Subject: [PATCH] feat: Exported getHistorySyncProgress function --- .../functions/getHistorySyncProgress.ts | 30 ++++++++ src/whatsapp/functions/index.ts | 1 + .../models/HistorySyncProgressModel.ts | 76 +++++++++++++++++++ src/whatsapp/models/index.ts | 1 + 4 files changed, 108 insertions(+) create mode 100644 src/whatsapp/functions/getHistorySyncProgress.ts create mode 100644 src/whatsapp/models/HistorySyncProgressModel.ts diff --git a/src/whatsapp/functions/getHistorySyncProgress.ts b/src/whatsapp/functions/getHistorySyncProgress.ts new file mode 100644 index 000000000..69af8d973 --- /dev/null +++ b/src/whatsapp/functions/getHistorySyncProgress.ts @@ -0,0 +1,30 @@ +/*! + * Copyright 2022 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 { exportModule } from '../exportModule'; + +/** + * @whatsapp 649959 >= 2.2244.5 + */ +export declare function getHistorySyncProgress(): any; + +exportModule( + exports, + { + getHistorySyncProgress: 'getHistorySyncProgress', + }, + (m) => m.getHistorySyncProgress +); diff --git a/src/whatsapp/functions/index.ts b/src/whatsapp/functions/index.ts index be4c6e758..e41416030 100644 --- a/src/whatsapp/functions/index.ts +++ b/src/whatsapp/functions/index.ts @@ -32,6 +32,7 @@ export * from './generateVideoThumbsAndDuration'; export * from './genMinimalLinkPreview'; export * from './getFanOutList'; export * from './getGroupSenderKeyList'; +export * from './getHistorySyncProgress'; export * from './getSearchContext'; export * from './groupParticipants'; export * from './handleAck'; diff --git a/src/whatsapp/models/HistorySyncProgressModel.ts b/src/whatsapp/models/HistorySyncProgressModel.ts new file mode 100644 index 000000000..f55ab26f8 --- /dev/null +++ b/src/whatsapp/models/HistorySyncProgressModel.ts @@ -0,0 +1,76 @@ +/*! + * 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 webpack from '../../webpack'; +import { exportModule } from '../exportModule'; +import { getHistorySyncProgress } from '../functions'; +import { + Model, + ModelOptions, + ModelPropertiesContructor, + ModelProxy, +} from './Model'; + +interface Props {} + +interface Session {} + +interface Derived { + progress: number | null; + paused: boolean; + inProgress: boolean; +} + +/** + * @whatsapp 649959 >= 2.2244.5 + */ +export declare interface HistorySyncProgressModel + extends ModelProxy {} + +/** + * @whatsapp 649959 >= 2.2244.5 + */ +export declare class HistorySyncProgressModel extends Model { + constructor( + proterties?: ModelPropertiesContructor, + options?: ModelOptions + ); + setInProgress(inProgress: boolean): void; + setPaused(paused: boolean): void; + setProgress(progress: number): void; +} + +exportModule( + exports, + { + HistorySyncProgressModel: 'HistorySyncProgressModel', + }, + (m) => m.HistorySyncProgressModel +); + +const fallback = {}; + +// Lazy load +Object.defineProperty(fallback, 'HistorySyncProgressModel', { + configurable: true, + enumerable: true, + get() { + const sync = getHistorySyncProgress(); + return sync.constructor; + }, +}); + +webpack.injectFallbackModule('HistorySyncProgressModel', fallback); diff --git a/src/whatsapp/models/index.ts b/src/whatsapp/models/index.ts index e98821b34..0c58a9b62 100644 --- a/src/whatsapp/models/index.ts +++ b/src/whatsapp/models/index.ts @@ -32,6 +32,7 @@ export * from './ContactModel'; export * from './ConversionTupleModel'; export * from './EmojiVariantModel'; export * from './GroupMetadataModel'; +export * from './HistorySyncProgressModel'; export * from './LabelItemModel'; export * from './LabelModel'; export * from './LiveLocationModel';