@@ -81,9 +81,9 @@ class GroupChat extends Chat {
8181 const participantData = { } ;
8282
8383 ! Array . isArray ( participantIds ) && ( participantIds = [ participantIds ] ) ;
84- const groupWid = window . Store . WidFactory . createWid ( groupId ) ;
85- const group = window . Store . Chat . get ( groupWid ) || ( await window . Store . Chat . find ( groupWid ) ) ;
86- const participantWids = participantIds . map ( ( p ) => window . Store . WidFactory . createWid ( p ) ) ;
84+ const groupWid = window . require ( 'WAWebWidFactory' ) . createWid ( groupId ) ;
85+ const group = ( window . require ( 'WAWebCollections' ) ) . Chat . get ( groupWid ) || ( await ( window . require ( 'WAWebCollections' ) ) . Chat . find ( groupWid ) ) ;
86+ const participantWids = participantIds . map ( ( p ) => window . require ( 'WAWebWidFactory' ) . createWid ( p ) ) ;
8787
8888 const errorCodes = {
8989 default : 'An unknown error occupied while adding a participant' ,
@@ -98,7 +98,7 @@ class GroupChat extends Chat {
9898 419 : 'The participant can\'t be added because the group is full'
9999 } ;
100100
101- await window . Store . GroupQueryAndUpdate ( { id : groupId } ) ;
101+ await ( window . require ( 'WAWebGroupQueryJob' ) ) . queryAndUpdateGroupMetadataById ( { id : groupId } ) ;
102102
103103 let groupParticipants = group . groupMetadata ?. participants . serialize ( ) ;
104104
@@ -111,7 +111,7 @@ class GroupChat extends Chat {
111111 }
112112
113113 groupParticipants . map ( ( { id } ) => {
114- return id . server === 'lid' ? window . Store . LidUtils . getPhoneNumber ( id ) : id ;
114+ return id . server === 'lid' ? window . require ( 'WAWebApiContact' ) . getPhoneNumber ( id ) : id ;
115115 } ) ;
116116
117117 const _getSleepTime = ( sleep ) => {
@@ -127,7 +127,7 @@ class GroupChat extends Chat {
127127
128128 for ( let pWid of participantWids ) {
129129 const pId = pWid . _serialized ;
130- pWid = pWid . server === 'lid' ? window . Store . LidUtils . getPhoneNumber ( pWid ) : pWid ;
130+ pWid = pWid . server === 'lid' ? window . require ( 'WAWebApiContact' ) . getPhoneNumber ( pWid ) : pWid ;
131131
132132 participantData [ pId ] = {
133133 code : undefined ,
@@ -141,7 +141,7 @@ class GroupChat extends Chat {
141141 continue ;
142142 }
143143
144- if ( ! ( await window . Store . QueryExist ( pWid ) ) ?. wid ) {
144+ if ( ! ( await ( window . require ( 'WAWebQueryExistsJob' ) . queryWidExists ) ( pWid ) ) ?. wid ) {
145145 participantData [ pId ] . code = 404 ;
146146 participantData [ pId ] . message = errorCodes [ 404 ] ;
147147 continue ;
@@ -157,12 +157,12 @@ class GroupChat extends Chat {
157157
158158 if ( autoSendInviteV4 && rpcResultCode === 403 ) {
159159 let userChat , isInviteV4Sent = false ;
160- window . Store . Contact . gadd ( pWid , { silent : true } ) ;
160+ ( window . require ( 'WAWebCollections' ) ) . Contact . gadd ( pWid , { silent : true } ) ;
161161
162162 if ( rpcResult . name === 'ParticipantRequestCodeCanBeSent' &&
163- ( userChat = window . Store . Chat . get ( pWid ) || ( await window . Store . Chat . find ( pWid ) ) ) ) {
163+ ( userChat = ( window . require ( 'WAWebCollections' ) ) . Chat . get ( pWid ) || ( await ( window . require ( 'WAWebCollections' ) ) . Chat . find ( pWid ) ) ) ) {
164164 const groupName = group . formattedTitle || group . name ;
165- const res = await window . Store . GroupInviteV4 . sendGroupInviteMessage (
165+ const res = await ( window . require ( 'WAWebChatSendMessages' ) ) . sendGroupInviteMessage (
166166 userChat ,
167167 group . id . _serialized ,
168168 groupName ,
@@ -201,7 +201,7 @@ class GroupChat extends Chat {
201201 return chat . groupMetadata . participants . get ( lid ?. _serialized ) ||
202202 chat . groupMetadata . participants . get ( phone ?. _serialized ) ;
203203 } ) ) ) . filter ( Boolean ) ;
204- await window . Store . GroupParticipants . removeParticipants ( chat , participants ) ;
204+ await ( window . require ( 'WAWebModifyParticipantsGroupAction' ) ) . removeParticipants ( chat , participants ) ;
205205 return { status : 200 } ;
206206 } , this . id . _serialized , participantIds ) ;
207207 }
@@ -220,7 +220,7 @@ class GroupChat extends Chat {
220220 return chat . groupMetadata . participants . get ( lid ?. _serialized ) ||
221221 chat . groupMetadata . participants . get ( phone ?. _serialized ) ;
222222 } ) ) ) . filter ( Boolean ) ;
223- await window . Store . GroupParticipants . promoteParticipants ( chat , participants ) ;
223+ await ( window . require ( 'WAWebModifyParticipantsGroupAction' ) ) . promoteParticipants ( chat , participants ) ;
224224 return { status : 200 } ;
225225 } , this . id . _serialized , participantIds ) ;
226226 }
@@ -239,7 +239,7 @@ class GroupChat extends Chat {
239239 return chat . groupMetadata . participants . get ( lid ?. _serialized ) ||
240240 chat . groupMetadata . participants . get ( phone ?. _serialized ) ;
241241 } ) ) ) . filter ( Boolean ) ;
242- await window . Store . GroupParticipants . demoteParticipants ( chat , participants ) ;
242+ await ( window . require ( 'WAWebModifyParticipantsGroupAction' ) ) . demoteParticipants ( chat , participants ) ;
243243 return { status : 200 } ;
244244 } , this . id . _serialized , participantIds ) ;
245245 }
@@ -251,9 +251,9 @@ class GroupChat extends Chat {
251251 */
252252 async setSubject ( subject ) {
253253 const success = await this . client . pupPage . evaluate ( async ( chatId , subject ) => {
254- const chatWid = window . Store . WidFactory . createWid ( chatId ) ;
254+ const chatWid = window . require ( 'WAWebWidFactory' ) . createWid ( chatId ) ;
255255 try {
256- await window . Store . GroupUtils . setGroupSubject ( chatWid , subject ) ;
256+ await ( window . require ( 'WAWebGroupModifyInfoJob' ) ) . setGroupSubject ( chatWid , subject ) ;
257257 return true ;
258258 } catch ( err ) {
259259 if ( err . name === 'ServerStatusCodeError' ) return false ;
@@ -273,12 +273,12 @@ class GroupChat extends Chat {
273273 */
274274 async setDescription ( description ) {
275275 const success = await this . client . pupPage . evaluate ( async ( chatId , description ) => {
276- const chatWid = window . Store . WidFactory . createWid ( chatId ) ;
276+ const chatWid = window . require ( 'WAWebWidFactory' ) . createWid ( chatId ) ;
277277 const chat = await window . WWebJS . getChat ( chatId , { getAsModel : false } ) ;
278278 let descId = chat . groupMetadata . descId ;
279- let newId = await window . Store . MsgKey . newId ( ) ;
279+ let newId = await ( window . require ( 'WAWebMsgKey' ) ) . newId ( ) ;
280280 try {
281- await window . Store . GroupUtils . setGroupDescription ( chatWid , description , newId , descId ) ;
281+ await ( window . require ( 'WAWebGroupModifyInfoJob' ) ) . setGroupDescription ( chatWid , description , newId , descId ) ;
282282 return true ;
283283 } catch ( err ) {
284284 if ( err . name === 'ServerStatusCodeError' ) return false ;
@@ -300,7 +300,7 @@ class GroupChat extends Chat {
300300 const success = await this . client . pupPage . evaluate ( async ( groupId , adminsOnly ) => {
301301 const chat = await window . WWebJS . getChat ( groupId , { getAsModel : false } ) ;
302302 try {
303- await window . Store . GroupUtils . setGroupProperty ( chat , 'member_add_mode' , adminsOnly ? 0 : 1 ) ;
303+ await ( window . require ( 'WAWebSetPropertyGroupAction' ) ) . setGroupProperty ( chat , 'member_add_mode' , adminsOnly ? 0 : 1 ) ;
304304 return true ;
305305 } catch ( err ) {
306306 if ( err . name === 'ServerStatusCodeError' ) return false ;
@@ -321,7 +321,7 @@ class GroupChat extends Chat {
321321 const success = await this . client . pupPage . evaluate ( async ( chatId , adminsOnly ) => {
322322 const chat = await window . WWebJS . getChat ( chatId , { getAsModel : false } ) ;
323323 try {
324- await window . Store . GroupUtils . setGroupProperty ( chat , 'announcement' , adminsOnly ? 1 : 0 ) ;
324+ await ( window . require ( 'WAWebSetPropertyGroupAction' ) ) . setGroupProperty ( chat , 'announcement' , adminsOnly ? 1 : 0 ) ;
325325 return true ;
326326 } catch ( err ) {
327327 if ( err . name === 'ServerStatusCodeError' ) return false ;
@@ -344,7 +344,7 @@ class GroupChat extends Chat {
344344 const success = await this . client . pupPage . evaluate ( async ( chatId , adminsOnly ) => {
345345 const chat = await window . WWebJS . getChat ( chatId , { getAsModel : false } ) ;
346346 try {
347- await window . Store . GroupUtils . setGroupProperty ( chat , 'restrict' , adminsOnly ? 1 : 0 ) ;
347+ await ( window . require ( 'WAWebSetPropertyGroupAction' ) ) . setGroupProperty ( chat , 'restrict' , adminsOnly ? 1 : 0 ) ;
348348 return true ;
349349 } catch ( err ) {
350350 if ( err . name === 'ServerStatusCodeError' ) return false ;
@@ -390,7 +390,7 @@ class GroupChat extends Chat {
390390 async getInviteCode ( ) {
391391 const codeRes = await this . client . pupPage . evaluate ( async chatId => {
392392 try {
393- return await window . Store . GroupInvite . fetchMexGroupInviteCode ( chatId ) ;
393+ return await ( window . require ( 'WAWebMexFetchGroupInviteCodeJob' ) ) . fetchMexGroupInviteCode ( chatId ) ;
394394 }
395395 catch ( err ) {
396396 if ( err . name === 'ServerStatusCodeError' ) return undefined ;
@@ -409,8 +409,8 @@ class GroupChat extends Chat {
409409 */
410410 async revokeInvite ( ) {
411411 const codeRes = await this . client . pupPage . evaluate ( chatId => {
412- const chatWid = window . Store . WidFactory . createWid ( chatId ) ;
413- return window . Store . GroupInvite . resetGroupInviteCode ( chatWid ) ;
412+ const chatWid = window . require ( 'WAWebWidFactory' ) . createWid ( chatId ) ;
413+ return ( window . require ( 'WAWebGroupQueryJob' ) ) . resetGroupInviteCode ( chatWid ) ;
414414 } , this . id . _serialized ) ;
415415
416416 return codeRes . code ;
@@ -474,7 +474,7 @@ class GroupChat extends Chat {
474474 async leave ( ) {
475475 await this . client . pupPage . evaluate ( async chatId => {
476476 const chat = await window . WWebJS . getChat ( chatId , { getAsModel : false } ) ;
477- return window . Store . GroupUtils . sendExitGroup ( chat ) ;
477+ return ( window . require ( 'WAWebExitGroupAction' ) ) . sendExitGroup ( chat ) ;
478478 } , this . id . _serialized ) ;
479479 }
480480
0 commit comments