-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1031,7 +1031,33 @@ export class SenderLayer extends ListenerLayer { | |
* @param chatId chat id: [email protected] | ||
*/ | ||
public async sendSeen(chatId: string) { | ||
return this.page.evaluate((chatId) => WAPI.sendSeen(chatId), chatId); | ||
return new Promise(async (resolve, reject) => { | ||
const typeFunction = 'markUnseenMessage'; | ||
const type = 'string'; | ||
const check = [ | ||
{ | ||
param: 'chatId', | ||
type: type, | ||
value: chatId, | ||
function: typeFunction, | ||
isUser: true, | ||
}, | ||
]; | ||
const validating = checkValuesSender(check); | ||
if (typeof validating === 'object') { | ||
return reject(validating); | ||
} | ||
const result = await this.page.evaluate( | ||
(chatId) => WAPI.sendSeen(chatId), | ||
chatId | ||
); | ||
|
||
if (result['erro'] == true) { | ||
return reject(result); | ||
} else { | ||
return resolve(result); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
export async function sendSeen(id, done) { | ||
if (!id) return false; | ||
var chat = window.WAPI.getChat(id); | ||
if (chat !== undefined) { | ||
await Store.ReadSeen.sendSeen(chat, false); | ||
done && done(true); | ||
const chat = await WAPI.sendExist(id); | ||
if (!chat.erro) { | ||
await Store.ReadSeen.markUnread(chat, false) | ||
.then(() => { | ||
return WAPI.scope(undefined, false, 'OK', null); | ||
}) | ||
.catch(() => { | ||
return WAPI.scope(undefined, true, 'Error', null); | ||
}); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
done && done(false); | ||
return false; | ||
} |