Skip to content

Commit

Permalink
fix: Fixed WPP.chat.archive function (close #1743) (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Mar 20, 2024
1 parent ce21995 commit d58e6d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/chat/functions/archive.ts
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

import { compare } from 'compare-versions';

import { assertGetChat, assertWid } from '../../assert';
import { WPPError } from '../../util';
import { Wid } from '../../whatsapp';
import { Cmd, Wid } from '../../whatsapp';
import { setArchive } from '../../whatsapp/functions';

/**
Expand Down Expand Up @@ -48,8 +50,11 @@ export async function archive(chatId: string | Wid, archive = true) {
{ wid, archive }
);
}

await setArchive(chat, archive);
if (compare(self.Debug.VERSION, '2.3000.0', '>=')) {
Cmd.archiveChat(chat, archive);
} else {
await setArchive(chat, archive);
}

return {
wid,
Expand Down
9 changes: 9 additions & 0 deletions src/whatsapp/functions/setArchive.ts
Expand Up @@ -18,16 +18,25 @@ import { exportModule } from '../exportModule';
import { ChatModel } from '../models';

/**
* @deprecated
* @whatsapp 59992
* @whatsapp 259992 >= 2.2222.8
* @whatsapp 503153 >= 2.2228.4
* <= 2.3000.x
*/
export declare function setArchive(
chat: ChatModel,
archive: boolean,
id?: string
): Promise<void>;

/**
* @whatsapp >= 2.3000.1012117641
*/
export declare function setArchive(
args: { id: string; archive: boolean }[]
): Promise<void>;

exportModule(
exports,
{
Expand Down

0 comments on commit d58e6d7

Please sign in to comment.