mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-19 05:58:29 +00:00
context-menu: Fix context menu indexing.
Addresses a problem where the context menu would get the incorrect index of server in sidebar and cause a crash when attempting to remove the server. Add comment justifying extra index parameter.
This commit is contained in:
committed by
Akash Nimare
parent
9bdc5dd9e4
commit
9e33ebae62
@@ -209,10 +209,10 @@ class ServerManagerView {
|
|||||||
$serverImgs.forEach(($serverImg, index) => {
|
$serverImgs.forEach(($serverImg, index) => {
|
||||||
this.addContextMenu($serverImg, index);
|
this.addContextMenu($serverImg, index);
|
||||||
if ($serverImg.src.includes('img/icon.png')) {
|
if ($serverImg.src.includes('img/icon.png')) {
|
||||||
this.displayInitialCharLogo($serverImg);
|
this.displayInitialCharLogo($serverImg, index);
|
||||||
}
|
}
|
||||||
$serverImg.addEventListener('error', () => {
|
$serverImg.addEventListener('error', () => {
|
||||||
this.displayInitialCharLogo($serverImg);
|
this.displayInitialCharLogo($serverImg, index);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,12 @@ class ServerManagerView {
|
|||||||
return currentIndex;
|
return currentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayInitialCharLogo($img) {
|
displayInitialCharLogo($img, index) {
|
||||||
|
/*
|
||||||
|
index parameter needed because webview[data-tab-id] can increment
|
||||||
|
beyond size of sidebar org array and throw error
|
||||||
|
*/
|
||||||
|
|
||||||
const $altIcon = document.createElement('div');
|
const $altIcon = document.createElement('div');
|
||||||
const $parent = $img.parentElement;
|
const $parent = $img.parentElement;
|
||||||
const $container = $parent.parentElement;
|
const $container = $parent.parentElement;
|
||||||
@@ -273,7 +278,7 @@ class ServerManagerView {
|
|||||||
$parent.removeChild($img);
|
$parent.removeChild($img);
|
||||||
$parent.appendChild($altIcon);
|
$parent.appendChild($altIcon);
|
||||||
|
|
||||||
this.addContextMenu($altIcon, $webview.getAttribute('data-tab-id'));
|
this.addContextMenu($altIcon, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarHoverEvent(SidebarButton, SidebarTooltip, addServer = false) {
|
sidebarHoverEvent(SidebarButton, SidebarTooltip, addServer = false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user