feat: add ability change column name on the fly (#180)

Co-authored-by: reya <reya@lume.nu>
This commit is contained in:
Ren Amamiya
2024-04-22 14:33:14 +07:00
committed by GitHub
co-authored by reya
parent 17766d29d6
commit c755b8d137
4 changed files with 70 additions and 9 deletions
@@ -89,6 +89,18 @@ function Screen() {
});
}, 150);
const updateName = useDebouncedCallback((label: string, title: string) => {
const currentColIndex = columns.findIndex((col) => col.label === label);
const updatedCol = Object.assign({}, columns[currentColIndex]);
updatedCol.name = title;
const newCols = columns.slice();
newCols[currentColIndex] = updatedCol;
setColumns(newCols);
}, 150);
const startResize = useDebouncedCallback(
() => setIsResize((prev) => !prev),
150,
@@ -111,6 +123,8 @@ function Screen() {
unlistenColEvent = await listen<EventColumns>("columns", (data) => {
if (data.payload.type === "add") add(data.payload.column);
if (data.payload.type === "remove") remove(data.payload.label);
if (data.payload.type === "set_title")
updateName(data.payload.label, data.payload.title);
});
unlistenWindowResize = await getCurrent().listen("tauri://resize", () => {