mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
[-] Remove method to add extra serialized props. This does not work, and the prop being added was already included.
This commit is contained in:
@@ -6,7 +6,7 @@ const moduleRaid = require('moduleraid/moduleraid');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const { WhatsWebURL, UserAgent, DefaultOptions, Events } = require('./util/Constants');
|
||||
const { ExposeStore, LoadExtraProps, LoadCustomSerializers } = require('./util/Injected');
|
||||
const { ExposeStore, LoadCustomSerializers } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const Chat = require('./structures/Chat');
|
||||
const Message = require('./structures/Message');
|
||||
@@ -65,7 +65,6 @@ class Client extends EventEmitter {
|
||||
|
||||
} else {
|
||||
// Wait for QR Code
|
||||
|
||||
const QR_CONTAINER_SELECTOR = '._2d3Jz';
|
||||
const QR_VALUE_SELECTOR = '._1pw2F';
|
||||
|
||||
@@ -97,20 +96,17 @@ class Client extends EventEmitter {
|
||||
// Check Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
//Load extra serialized props
|
||||
const models = [Message];
|
||||
for (let model of models) {
|
||||
await page.evaluate(LoadExtraProps, model.WAppModel, model.extraFields);
|
||||
}
|
||||
|
||||
//Load custom serializers
|
||||
await page.evaluate(LoadCustomSerializers);
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
const message = new Message(this, msg);
|
||||
this.emit(Events.MESSAGE_CREATE, message);
|
||||
|
||||
if (msg.id.fromMe || !msg.isNewMsg) return;
|
||||
if (msg.id.fromMe) return;
|
||||
this.emit(Events.MESSAGE_RECEIVED, message);
|
||||
});
|
||||
|
||||
|
||||
@@ -17,23 +17,6 @@ class Base {
|
||||
}
|
||||
|
||||
_patch(data) { return data; }
|
||||
|
||||
/**
|
||||
* Name that represents this model in the WhatsApp Web Store
|
||||
* @readonly
|
||||
*/
|
||||
static get WAppModel() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra fields to add to model serialization
|
||||
* @readonly
|
||||
*/
|
||||
static get extraFields() {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Base;
|
||||
@@ -60,16 +60,6 @@ class Message extends Base {
|
||||
|
||||
}, chatId, this.id._serialized, message);
|
||||
}
|
||||
|
||||
static get WAppModel() {
|
||||
return 'Msg';
|
||||
}
|
||||
|
||||
static get extraFields() {
|
||||
return [
|
||||
'isNewMsg'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
@@ -11,13 +11,6 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
window.Store.SendMessage = window.mR.findModule("sendTextMsgToChat")[0].sendTextMsgToChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds extra props to the serialization of a model
|
||||
*/
|
||||
exports.LoadExtraProps = (model, props) => {
|
||||
Store[model].models[0].__props = Store[model].models[0].__props.concat(props);
|
||||
}
|
||||
|
||||
exports.LoadCustomSerializers = () => {
|
||||
window.WWebJS = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user