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.

Fix Travis errors
  • Loading branch information
kanishk98 committed Jan 22, 2019
1 parent 9bce119 commit 7774da8
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 @@ -159,22 +159,24 @@ class ServerManagerView {
const showSidebar = ConfigUtil.getConfigItem('showSidebar', true);
this.toggleSidebar(showSidebar);
// Allow dragging of server tabs and update the data-tab-id
const onEnd = event => {
const onEnd = () => {
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 @@ -238,6 +240,10 @@ class ServerManagerView {
const onHoverOut = this.onHoverOut.bind(this, oldIndex);
this.tabs[index].updateListeners(onClick, onHover, onHoverOut);
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 7774da8

Please sign in to comment.