Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix archive conversation issues #732

Merged
merged 19 commits into from
Jan 20, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ ipc.on('delete-conversation', () => {
});

ipc.on('archive-conversation', () => {
const index = getNextIndex(true);
openArchiveModal();
jumpToConversation(index);
});

function setSidebarVisibility() {
Expand Down Expand Up @@ -256,8 +258,8 @@ function jumpToConversation(key) {
}

// Focus on the conversation with the given index
function selectConversation(index) {
document.querySelector(listSelector).children[index].firstChild.firstChild.click();
async function selectConversation(index) {
(await elementReady(listSelector)).children[index].firstChild.firstChild.click();
}

// Returns the index of the selected conversation.
Expand Down Expand Up @@ -319,7 +321,11 @@ function openArchiveModal() {
return;
}

selectMenuItem(3);
// Check if selected conversation is a group
// In case it is we need to click on 4th element of conversation menu, otherwise 3rd
const isGroup = document.querySelector('._54nq._2i-c._150g._558b._2n_z li:nth-child(3) a span span').innerHTML === 'Leave Group';

selectMenuItem(isGroup ? 4 : 3);
}

function openDeleteModal() {
Expand All @@ -332,7 +338,7 @@ function openDeleteModal() {

async function openPreferences() {
// Create the menu for the below
(await elementReady('._30yy._2fug._p')).click();
showSettingsMenu();

selectMenuItem(1);
}
Expand All @@ -347,7 +353,7 @@ function closePreferences() {
}
async function sendConversationList() {
const conversations = await Promise.all(
[...document.querySelector(listSelector).children]
[...(await elementReady(listSelector)).children]
.splice(0, 10)
.map(async el => {
const profilePic = el.querySelector('._55lt img');
Expand Down