mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-13 02:00:10 +01:00
[FEAT] Thread bulk edit UX improvements (#1520)
* update thread bulk edit ux to hold cmd/ctrl to appear + rename default new thread to avoid confusion * revert new thread defualt name change * unset undelete threads * comment --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
This commit is contained in:
parent
6a2d7aca28
commit
649d0d79eb
@ -22,11 +22,17 @@ export default function ThreadContainer({ workspace }) {
|
|||||||
fetchThreads();
|
fetchThreads();
|
||||||
}, [workspace.slug]);
|
}, [workspace.slug]);
|
||||||
|
|
||||||
// Enable toggling of meta-key (ctrl on win and cmd/fn on others)
|
// Enable toggling of bulk-deletion by holding meta-key (ctrl on win and cmd/fn on others)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (event) => {
|
const handleKeyDown = (event) => {
|
||||||
if (["Control", "Meta"].includes(event.key)) {
|
if (["Control", "Meta"].includes(event.key)) {
|
||||||
setCtrlPressed((prev) => !prev);
|
setCtrlPressed(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyUp = (event) => {
|
||||||
|
if (["Control", "Meta"].includes(event.key)) {
|
||||||
|
setCtrlPressed(false);
|
||||||
// when toggling, unset bulk progress so
|
// when toggling, unset bulk progress so
|
||||||
// previously marked threads that were never deleted
|
// previously marked threads that were never deleted
|
||||||
// come back to life.
|
// come back to life.
|
||||||
@ -37,9 +43,13 @@ export default function ThreadContainer({ workspace }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("keydown", handleKeyDown);
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
|
window.addEventListener("keyup", handleKeyUp);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("keydown", handleKeyDown);
|
window.removeEventListener("keydown", handleKeyDown);
|
||||||
|
window.removeEventListener("keyup", handleKeyUp);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -56,7 +66,6 @@ export default function ThreadContainer({ workspace }) {
|
|||||||
const slugs = threads.filter((t) => t.deleted === true).map((t) => t.slug);
|
const slugs = threads.filter((t) => t.deleted === true).map((t) => t.slug);
|
||||||
await Workspace.threads.deleteBulk(workspace.slug, slugs);
|
await Workspace.threads.deleteBulk(workspace.slug, slugs);
|
||||||
setThreads((prev) => prev.filter((t) => !t.deleted));
|
setThreads((prev) => prev.filter((t) => !t.deleted));
|
||||||
setCtrlPressed(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeThread(threadId) {
|
function removeThread(threadId) {
|
||||||
@ -89,6 +98,7 @@ export default function ThreadContainer({ workspace }) {
|
|||||||
)
|
)
|
||||||
? threads.findIndex((thread) => thread?.slug === threadSlug) + 1
|
? threads.findIndex((thread) => thread?.slug === threadSlug) + 1
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col" role="list" aria-label="Threads">
|
<div className="flex flex-col" role="list" aria-label="Threads">
|
||||||
<ThreadItem
|
<ThreadItem
|
||||||
|
Loading…
Reference in New Issue
Block a user