Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Chat.isMuted #2999

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

fix: Chat.isMuted #2999

wants to merge 5 commits into from

Conversation

alechkos
Copy link
Collaborator

@alechkos alechkos commented May 1, 2024

Table of Contents

- Description

- Related Issues

- I Want to Test this PR

- I Got an Error While Testing This PR ❌

- How Has the PR Been Tested (latest test on 01.05.2024)

- Types of Changes


Description

Changes:

  1. Chat.isMuted property now shows valid value (and not undefined)
  2. Each time the Chat.mute or Chat.unmute methods are called, the isMuted and muteExpiration properties of Chat instance are updated as expected
  3. Methods Chat.mute, Chat.unmute, Client.muteChat, Client.unmuteChat now return
    Promise<{ isMuted: boolean, muteExpiration: number }> instead of Promise<void>, for more clarity

Related Issues

The PR closes #2781, closes #2800, closes #2801


To test this PR by yourself you should do two steps:

1. Install the PR by running one of the following commands:

  • NPM
npm install github:alechkos/whatsapp-web.js#fix-ismuted
  • YARN
yarn add github:alechkos/whatsapp-web.js#fix-ismuted

2. Lock your WWeb version on 2.2412.54:

const wwebVersion = '2.2412.54';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    // locking the wweb version
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

If you encounter any errors while testing this PR, please provide in a comment:

  1. The code you've used without any sensitive information (use syntax highlighting for more readability)
  2. The error you got
  3. The library version
  4. The WWeb version: console.log(await client.getWWebVersion());
  5. The browser (Chrome/Chromium)

Important

You have to reapply the PR each time it is changed (new commits were pushed since your last application)


How Has The PR Been Tested (latest test on 01.05.2024)

Tested with a code:

// client initialization...

client.on('message', async (msg) => {
    const chat = await msg.getChat(); // chat is unmuted here
    console.log(chat.mute()); // expected output: { isMuted: true, muteExpiration: -1 }
    console.log(chat.isMuted, chat.muteExpiration); // expected output: true -1
    console.log(chat.unmute()); // expected output: { isMuted: false, muteExpiration: 0 }
    console.log(chat.isMuted, chat.muteExpiration); // expected output: false 0
});

Tested On:

Types of accounts:

  • Personal
  • Buisness

Environment:

  • Android 10:
    • WhatsApp: latest
    • WA Business: latest
  • Windows 10:
    • WWebJS: v1.23.1-alpha.6
    • WWeb: v2.2412.54
    • Puppeteer: v18.2.1
    • Node: v18.17.1
    • Chrome: latest

Types of Changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix/feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • I have updated the usage example accordingly (example.js)
  • I have updated the documentation accordingly (index.d.ts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant