@@ -21,7 +21,8 @@ async function withMenu(
21
21
menuButtonElement . click ( ) ;
22
22
23
23
// Wait for the menu to close before removing the 'hide-dropdowns' class
24
- const menuLayer = document . querySelector ( '.j83agx80.cbu4d94t.l9j0dhe7.jgljxmt5.be9z9djy > div:nth-child(2) > div' ) ;
24
+ await elementReady ( '.x78zum5.xdt5ytf.x1n2onr6.xat3117.xxzkxad > div:nth-child(2) > div' , { stopOnDomReady : false } ) ;
25
+ const menuLayer = document . querySelector ( '.x78zum5.xdt5ytf.x1n2onr6.xat3117.xxzkxad > div:nth-child(2) > div' ) ;
25
26
26
27
if ( menuLayer ) {
27
28
const observer = new MutationObserver ( ( ) => {
@@ -228,11 +229,11 @@ ipc.answerMain('delete-conversation', async () => {
228
229
await deleteSelectedConversation ( ) ;
229
230
} ) ;
230
231
231
- ipc . answerMain ( 'hide -conversation' , async ( ) => {
232
+ ipc . answerMain ( 'archive -conversation' , async ( ) => {
232
233
const index = selectedConversationIndex ( ) ;
233
234
234
235
if ( index !== - 1 ) {
235
- await hideSelectedConversation ( ) ;
236
+ await archiveSelectedConversation ( ) ;
236
237
237
238
const key = index + 1 ;
238
239
await jumpToConversation ( key ) ;
@@ -594,7 +595,7 @@ function selectedConversationIndex(offset = 0): number {
594
595
return - 1 ;
595
596
}
596
597
597
- const newSelected = selected . parentNode ! . parentNode ! . parentNode ! as HTMLElement ;
598
+ const newSelected = selected . closest ( ` ${ selectors . conversationList } > div` ) ! ;
598
599
599
600
const list = [ ...newSelected . parentNode ! . children ] ;
600
601
const index = list . indexOf ( newSelected ) + offset ;
@@ -611,7 +612,7 @@ async function setZoom(zoomFactor: number): Promise<void> {
611
612
async function withConversationMenu ( callback : ( ) => void ) : Promise < void > {
612
613
// eslint-disable-next-line @typescript-eslint/ban-types
613
614
let menuButton : HTMLElement | null = null ;
614
- const conversation = document . querySelector < HTMLElement > ( `${ selectors . selectedConversation } ` ) ?. parentElement ?. parentElement ?. parentElement ?. parentElement ;
615
+ const conversation = document . querySelector < HTMLElement > ( selectors . selectedConversation ) ! . closest ( `${ selectors . conversationList } > div` ) ;
615
616
616
617
menuButton = conversation ?. querySelector ( '[aria-label=Menu][role=button]' ) ?? null ;
617
618
@@ -637,16 +638,16 @@ function isSelectedConversationGroup(): boolean {
637
638
return Boolean ( document . querySelector < HTMLElement > ( `${ selectors . conversationMenuSelectorNewDesign } [role=menuitem]:nth-child(4)` ) ) ;
638
639
}
639
640
640
- async function hideSelectedConversation ( ) : Promise < void > {
641
+ async function archiveSelectedConversation ( ) : Promise < void > {
641
642
await withConversationMenu ( ( ) => {
642
- const [ isGroup , isNotGroup ] = [ 5 , 6 ] ;
643
+ const [ isGroup , isNotGroup ] = [ - 4 , - 3 ] ;
643
644
selectMenuItem ( isSelectedConversationGroup ( ) ? isGroup : isNotGroup ) ;
644
645
} ) ;
645
646
}
646
647
647
648
async function deleteSelectedConversation ( ) : Promise < void > {
648
649
await withConversationMenu ( ( ) => {
649
- const [ isGroup , isNotGroup ] = [ 6 , 7 ] ;
650
+ const [ isGroup , isNotGroup ] = [ - 3 , - 2 ] ;
650
651
selectMenuItem ( isSelectedConversationGroup ( ) ? isGroup : isNotGroup ) ;
651
652
} ) ;
652
653
}
0 commit comments