mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-19 14:08:31 +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) => {
|
||||
this.addContextMenu($serverImg, index);
|
||||
if ($serverImg.src.includes('img/icon.png')) {
|
||||
this.displayInitialCharLogo($serverImg);
|
||||
this.displayInitialCharLogo($serverImg, index);
|
||||
}
|
||||
$serverImg.addEventListener('error', () => {
|
||||
this.displayInitialCharLogo($serverImg);
|
||||
this.displayInitialCharLogo($serverImg, index);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -253,7 +253,12 @@ class ServerManagerView {
|
||||
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 $parent = $img.parentElement;
|
||||
const $container = $parent.parentElement;
|
||||
@@ -273,7 +278,7 @@ class ServerManagerView {
|
||||
$parent.removeChild($img);
|
||||
$parent.appendChild($altIcon);
|
||||
|
||||
this.addContextMenu($altIcon, $webview.getAttribute('data-tab-id'));
|
||||
this.addContextMenu($altIcon, index);
|
||||
}
|
||||
|
||||
sidebarHoverEvent(SidebarButton, SidebarTooltip, addServer = false) {
|
||||
|
||||
Reference in New Issue
Block a user