From 517e22381a4c420ca081dbae7b9f8ef881a3c5c6 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Sun, 8 Sep 2019 03:54:44 -0400 Subject: [PATCH] [-] Remove method to add extra serialized props. This does not work, and the prop being added was already included. --- src/Client.js | 14 +++++--------- src/structures/Base.js | 17 ----------------- src/structures/Message.js | 10 ---------- src/util/Injected.js | 7 ------- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/src/Client.js b/src/Client.js index cb384f6..b5bd3ff 100644 --- a/src/Client.js +++ b/src/Client.js @@ -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); }); diff --git a/src/structures/Base.js b/src/structures/Base.js index 4fb4bdd..21023a9 100644 --- a/src/structures/Base.js +++ b/src/structures/Base.js @@ -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; \ No newline at end of file diff --git a/src/structures/Message.js b/src/structures/Message.js index c8f8a17..fb98efe 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -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; \ No newline at end of file diff --git a/src/util/Injected.js b/src/util/Injected.js index 17faa27..62e90d0 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -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 = {};