[-] Remove method to add extra serialized props. This does not work, and the prop being added was already included.

This commit is contained in:
Pedro Lopez
2019-09-08 03:54:44 -04:00
parent 18199d8120
commit 517e22381a
4 changed files with 5 additions and 43 deletions

View File

@@ -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);
});

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 = {};