-
-
Notifications
You must be signed in to change notification settings - Fork 429
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 flashing icons of servers in sidebar #621
Conversation
It should call initServer in the order in which the domains.json saves the file. I am not too sure if the changes you have done would lead us a good final solution. This part to implement is a bit tricky keeping in mind the user experience. You could try experimenting a bit on this. Understanding the function call orders with indexes should definitely help. |
@kanishk98 I don't think your code logic is correct. For me refreshing, causes me to lose a server. Clicking on 2nd tab opens the 3rd tab, the order of tabs changes on its own on refreshing. |
@abhigyank thanks for the feedback. I'll see what might've caused you to lose a server and change the click behaviour. As for changing the order of tabs, I'm loading the last active tab as the first server in the list on every refresh. I assumed that we'd want that to be the first tab. Is that what you mean by the incorrect order? |
I think we'd want that to the be the first tab to load but not necessarily the first tab in the list on the left sidebar. The order on the sidebar should remain same but only the loading order could vary. @akashnimare Feel free to weigh in here. |
@abhigyank What I understand from the previous comments is that we'd want to initialize the servers in the sidebar as per their original order, but the actual loading of their webviews happens only after the last active tab has been activated. If that's the case, I've changed my initTabs() {
const servers = DomainUtil.getDomains();
if (servers.length > 0) {
for (let i = 0; i < servers.length; i++) {
this.initServer(servers[i], i);
DomainUtil.updateSavedServer(servers[i].url, i);
}
// activate last active tab and load its webview first
const lastActiveTab = ConfigUtil.getConfigItem('lastActiveTab');
this.activateTab(lastActiveTab);
for (let i = 0; i < servers.length; i++) {
if (i === lastActiveTab) {
continue;
}
this.tabs[i].loadWebview();
}
// Remove focus from the settings icon at sidebar bottom
this.$settingsButton.classList.remove('active');
} else {
this.openSettings('AddServer');
}
} If you think I've got the correct idea now, I'll push this code. |
@akashnimare @abhigyank does this PR look good? Edit: I'm guessing the work on this PR is done and waiting review. I'll remove the WIP tag; please let me know if there is something else that needs to be done. |
Need some time to review this :) |
@kanishk98 can you fix the merge conflicts? Also, the desired behaviour should be -
|
9300d6b
to
8a087a3
Compare
Updated this PR's logic and also fixed the merge conflicts. |
@kanishk98 can we make the code cleaner a bit, maybe something like this - let lastActiveTab = ConfigUtil.getConfigItem('lastActiveTab');
if (lastActiveTab >= servers.length) {
lastActiveTab = 0;
}
// Following is the logic to handle which webview we need to load first
for (let i = 0; i < servers.length; i++) {
if (i === lastActiveTab) {
// load last active tab first
DomainUtil.updateSavedServer(servers[lastActiveTab].url, lastActiveTab);
this.activateTab(lastActiveTab);
continue;
}
// load other webviews
DomainUtil.updateSavedServer(servers[i].url, i);
this.tabs[i].webview.load();
} |
@akashnimare wouldn't the above snippet load them in order anyway? We would activate only the last active server, yes, but don't we also want to load that one first? |
8a087a3
to
44740ea
Compare
Merged. Thanks, @kanishk98. |
What's this PR do?
Changes order in which servers are loaded and rendered in the sidebar. I'd like to stop doing the latter half by retaining the server tabs
Any background context you want to provide?
#551 should provide the required context.
I've changed the order of loading servers, but rendering items in the sidebar according to the old order is turning out to be a problem (my understanding of how
initServer()
works is faulty here. Does it not renderthis.tabs
inapp/renderer/js/main.js
according to the order in which the elements are present in the array?)This problem is similar to the one I'm currently facing in https://github.com/zulip/zulip-electron/pull/617.
Screenshots? (according to zulip/zulip-electron@3ec20ca, last updated on Jan 7)
The refresh you see has been forced by me.
You have tested this PR on: