Skip to content

Commit

Permalink
Update workflowEditorCommentStore set/del for vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Nov 11, 2023
1 parent 2eeb6d8 commit 77ab273
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions client/src/stores/workflowEditorCommentStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { computed, del, ref, set } from "vue";
import { computed, ref } from "vue";

import type { Color } from "@/components/Workflow/Editor/Comments/colors";
import {
Expand Down Expand Up @@ -112,7 +112,7 @@ export const useWorkflowCommentStore = (workflowId: string) => {
newComment.position[0] += defaultPosition[0];
newComment.position[1] += defaultPosition[1];

set(commentsRecord.value, newComment.id, newComment);
commentsRecord.value[newComment.id] = newComment;
});
};

Expand All @@ -128,23 +128,23 @@ export const useWorkflowCommentStore = (workflowId: string) => {

function changePosition(id: number, position: [number, number]) {
const comment = getComment.value(id);
set(comment, "position", vecReduceFigures(position));
comment.position = vecReduceFigures(position);
}

function changeSize(id: number, size: [number, number]) {
const comment = getComment.value(id);
set(comment, "size", vecReduceFigures(size));
comment.size = vecReduceFigures(size);
}

function changeData(id: number, data: unknown) {
const comment = getComment.value(id);
assertCommentDataValid(comment.type, data);
set(comment, "data", data);
comment.data = data;
}

function changeColor(id: number, color: WorkflowCommentColor) {
const comment = getComment.value(id);
set(comment, "color", color);
comment.color = color;
}

function addPoint(id: number, point: [number, number]) {
Expand All @@ -165,7 +165,7 @@ export const useWorkflowCommentStore = (workflowId: string) => {
}

function deleteComment(id: number) {
del(commentsRecord.value, id);
delete commentsRecord.value[id];
}

/**
Expand All @@ -182,17 +182,17 @@ export const useWorkflowCommentStore = (workflowId: string) => {
const metadata = localCommentsMetadata.value[id];

if (metadata) {
set(metadata, "justCreated", true);
metadata.justCreated = true;
} else {
set(localCommentsMetadata.value, id, { justCreated: true });
localCommentsMetadata.value[id] = { justCreated: true };
}
}

function clearJustCreated(id: number) {
const metadata = localCommentsMetadata.value[id];

if (metadata) {
del(metadata, "justCreated");
delete metadata.justCreated;
}
}

Expand Down

0 comments on commit 77ab273

Please sign in to comment.