-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
base: main
Are you sure you want to change the base?
Conversation
875e22d
to
7879f70
Compare
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. |
1ce8837
to
aedab17
Compare
Updated it... Let me know if any other changes are required... |
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? |
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? |
There was a problem hiding this 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)
app/renderer/js/main.ts
Outdated
@@ -81,6 +82,7 @@ export class ServerManagerView { | |||
tabIndex: number; | |||
presetOrgs: string[]; | |||
preferenceView?: PreferenceView; | |||
sortableSidebar: SortableJS | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sortableSidebar: SortableJS | null; | |
sortableSidebar?: SortableJS; |
to avoid explicitly assigning null
.
app/renderer/js/main.ts
Outdated
animation: 150, | ||
onEnd: (event: SortableJS.SortableEvent) => { | ||
// Update the domain order in the database | ||
DomainUtil.updateDomainOrder(event.oldIndex ?? 0, event.newIndex ?? 0); |
There was a problem hiding this comment.
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
.
app/renderer/js/utils/domain-util.ts
Outdated
const domains = serverConfSchema | ||
.array() | ||
.parse(db.getObject<unknown>("/domains")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use getDomains()
?
app/renderer/js/utils/domain-util.ts
Outdated
const [movedDomain] = domains.splice(oldIndex, 1); | ||
domains.splice(newIndex, 0, movedDomain); |
There was a problem hiding this comment.
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.
app/renderer/js/utils/domain-util.ts
Outdated
for (const [index, domain] of domains.entries()) { | ||
updateDomain(index, domain); | ||
} |
There was a problem hiding this comment.
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
"@types/sortablejs": "^1.15.8", | ||
"gatemaker": "https://github.com/andersk/gatemaker/archive/d31890ae1cb293faabcb1e4e465c673458f6eed2.tar.gz", | ||
"sortablejs": "^1.15.2" |
There was a problem hiding this comment.
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.)
Made all the changes... not sure what can be done about the warning that you are getting, Any ideas? |
ec8ecc9
to
12ad3a2
Compare
I think this is good to release, as the test is showing a false negative... |
12ad3a2
to
21cfd2c
Compare
21cfd2c
to
a058716
Compare
a058716
to
64e827a
Compare
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? |
@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. |
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: