Skip to content

Commit

Permalink
Fix webview freeze
Browse files Browse the repository at this point in the history
Addresses an issue where org webviews would freeze after dragging server
icons in the sidebar.
  • Loading branch information
kanishk98 committed Jan 21, 2019
1 parent 9bce119 commit 171ff4b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/renderer/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,21 @@ class ServerManagerView {
const onEnd = event => {
const newTabs = [];
const domains = [];
const indexMap = {};
const tabElements = document.querySelectorAll('#tabs-container .tab');
tabElements.forEach((el, index) => {
const oldIndex = +Number(el.getAttribute('data-tab-id')) % tabElements.length;
el.setAttribute('data-tab-id', index.toString());
domains.push(DomainUtil.getDomain(oldIndex));
newTabs.push(this.tabs[oldIndex]);
indexMap[String(oldIndex)] = index;
this.replaceServer(domains[index], index, oldIndex);
});
for (let index = 0; index < domains.length; ++index) {
DomainUtil.updateSavedServer(domains[index].url, index);
}
this.activeTabIndex = indexMap[String(this.activeTabIndex)];
this.tabs = newTabs;
this.activeTabIndex = event.newIndex;
ipcRenderer.send('update-menu', {
tabs: this.tabs,
activeTabIndex: this.activeTabIndex
Expand Down Expand Up @@ -237,7 +239,11 @@ class ServerManagerView {
const onHover = this.onHover.bind(this, oldIndex);
const onHoverOut = this.onHoverOut.bind(this, oldIndex);
this.tabs[index].updateListeners(onClick, onHover, onHoverOut);
this.tabs[index].updateShortcutText(index);
this.tabs[index].updateShortcutText(index);``
this.tabs[index].webview.props.index = index;
this.tabs[index].webview.props.isActive = () => {
return oldIndex === this.activeTabIndex;
};
}

initActions() {
Expand Down

0 comments on commit 171ff4b

Please sign in to comment.