Skip to content
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

Left sidebar: Added ordering feature for server tabs #1359

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Aitchessbee
Copy link
Collaborator

@Aitchessbee Aitchessbee commented Mar 13, 2024

What's this PR do?
fixes #548
Ordering feature for server tabs using drag and drop

Libraries added - SortableJS, @types/sortablejs

You have tested this PR on:

  • Windows
  • Linux/Ubuntu
  • macOS

@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch from 875e22d to 7879f70 Compare March 13, 2024 13:38
@timabbott
Copy link
Member

Can you clean up this PR? Check out the Zulip commit guidelines for more details, but also please take the time to read our contributing guidelines and advice for creating reviewable pull requests.

@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch from 1ce8837 to aedab17 Compare March 14, 2024 08:25
@Aitchessbee
Copy link
Collaborator Author

Can you clean up this PR? Check out the Zulip commit guidelines for more details, but also please take the time to read our contributing guidelines and advice for creating reviewable pull requests.

Updated it... Let me know if any other changes are required...

@Aitchessbee Aitchessbee changed the title Added ordering feature for server tabs Left sidebar: Added ordering feature for server tabs - fixes #548 Mar 14, 2024
@Aitchessbee Aitchessbee changed the title Left sidebar: Added ordering feature for server tabs - fixes #548 Left sidebar: Added ordering feature for server tabs Mar 14, 2024
@timabbott
Copy link
Member

Thoughts on #1059 (comment)? Is the strategy for this PR that you're just doing a hard-reload of the app to avoid having to solve that problem?

@Aitchessbee
Copy link
Collaborator Author

Yeah! Server reordering is not something a user is not going to be doing very often, and given the complications of the index issues we'll be facing through other approaches, I found hard reloading to be the best way to ensure everything works properly. What are your thoughts on this?

Copy link
Member

@andersk andersk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I’m seeing an issue where horizontal scrolling gets triggered during drag (maybe by a tooltip?).

  • Repeatedly hard-reloading the app seems to mildly annoy Electron:

    (node:807197) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 render-view-deleted listeners added to [WebContents]. Use emitter.setMaxListeners() to increase limit
        at _addListener (node:events:591:17)
        at WebContents.addListener (node:events:609:10)
        at ObjectsRegistry.registerDeleteListener (/home/anders/zulip/zulip-desktop/dist-electron/index.js:190:17)
        at ObjectsRegistry.add (/home/anders/zulip/zulip-desktop/dist-electron/index.js:115:12)
        at valueToMeta (/home/anders/zulip/zulip-desktop/dist-electron/index.js:431:40)
        at /home/anders/zulip/zulip-desktop/dist-electron/index.js:655:14
        at IpcMainImpl.<anonymous> (/home/anders/zulip/zulip-desktop/dist-electron/index.js:585:23)
        at IpcMainImpl.emit (node:events:517:28)
        at IpcMainImpl.emit (node:domain:489:12)
    

@@ -81,6 +82,7 @@ export class ServerManagerView {
tabIndex: number;
presetOrgs: string[];
preferenceView?: PreferenceView;
sortableSidebar: SortableJS | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sortableSidebar: SortableJS | null;
sortableSidebar?: SortableJS;

to avoid explicitly assigning null.

animation: 150,
onEnd: (event: SortableJS.SortableEvent) => {
// Update the domain order in the database
DomainUtil.updateDomainOrder(event.oldIndex ?? 0, event.newIndex ?? 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected data should be rejected and ignored, not silently replaced with fake values like 0.

Comment on lines 76 to 78
const domains = serverConfSchema
.array()
.parse(db.getObject<unknown>("/domains"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use getDomains()?

Comment on lines 80 to 81
const [movedDomain] = domains.splice(oldIndex, 1);
domains.splice(newIndex, 0, movedDomain);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the database is out of sync (e.g. it has been manually edited), it’s possible for oldIndex and newIndex to be out of range. We should check for that.

Comment on lines 84 to 86
for (const [index, domain] of domains.entries()) {
updateDomain(index, domain);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this in a single db.push call, not one call per domain.

package.json Outdated
Comment on lines 146 to 148
"@types/sortablejs": "^1.15.8",
"gatemaker": "https://github.com/andersk/gatemaker/archive/d31890ae1cb293faabcb1e4e465c673458f6eed2.tar.gz",
"sortablejs": "^1.15.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sortablejs and @types/sortablejs should go in devDependencies as they are bundled by Vite. (gatemaker is a weird exception due to the native library it uses on macOS.)

@Aitchessbee
Copy link
Collaborator Author

  • I’m seeing an issue where horizontal scrolling gets triggered during drag (maybe by a tooltip?).
  • Repeatedly hard-reloading the app seems to mildly annoy Electron:
    (node:807197) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 render-view-deleted listeners added to [WebContents]. Use emitter.setMaxListeners() to increase limit
        at _addListener (node:events:591:17)
        at WebContents.addListener (node:events:609:10)
        at ObjectsRegistry.registerDeleteListener (/home/anders/zulip/zulip-desktop/dist-electron/index.js:190:17)
        at ObjectsRegistry.add (/home/anders/zulip/zulip-desktop/dist-electron/index.js:115:12)
        at valueToMeta (/home/anders/zulip/zulip-desktop/dist-electron/index.js:431:40)
        at /home/anders/zulip/zulip-desktop/dist-electron/index.js:655:14
        at IpcMainImpl.<anonymous> (/home/anders/zulip/zulip-desktop/dist-electron/index.js:585:23)
        at IpcMainImpl.emit (node:events:517:28)
        at IpcMainImpl.emit (node:domain:489:12)
    

Made all the changes... not sure what can be done about the warning that you are getting, Any ideas?

@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch 2 times, most recently from ec8ecc9 to 12ad3a2 Compare March 24, 2024 19:35
@Aitchessbee
Copy link
Collaborator Author

I think this is good to release, as the test is showing a false negative...

@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch from 12ad3a2 to 21cfd2c Compare April 14, 2024 09:39
@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch from 21cfd2c to a058716 Compare April 23, 2024 09:51
@Aitchessbee Aitchessbee force-pushed the feature/sidebar-orgs-ordering branch from a058716 to 64e827a Compare April 23, 2024 09:54
@jni
Copy link

jni commented Oct 28, 2024

Hello Zulip team! As per usual, thank you so much for Zulip! Actually Zulip itself brought me here — thanks to the awesome organisation I was able to find recent topics discussing this feature and find my way to this PR, saving noise and duplication for everyone. 🥳

It seems like this PR is ready for another round of review?

@alya
Copy link
Collaborator

alya commented Oct 30, 2024

@Aitchessbee Please clean up your commit history and post again to request a review. See here for guidelines.

You will also need to resolve conflicts.

@zulipbot
Copy link
Member

Heads up @Aitchessbee, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the org tab list draggable in left sidebar
6 participants