Skip to content

Commit

Permalink
resolve: #135
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Oct 24, 2023
1 parent 616952c commit 59fb70a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/utils/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,30 @@ async function applyAction(rule: ActionData, args: ActionArgs) {
.map((tag) => tag.trim())
.filter((tag) => tag);
let message: string = "";
let hasChanged = false;
switch (rule.operation) {
case ActionOperationTypes.add: {
for (const tag of tags) {
item?.addTag(tag, 1);
if (!item?.hasTag(tag)) {
hasChanged || (hasChanged = true);
item?.addTag(tag, 1);
}
}
message = `Add tag ${tags.join(",")} to item ${item?.getField("title")}`;
message = hasChanged
? `Add tag ${tags.join(",")} to item ${item?.getField("title")}`
: "";
break;
}
case ActionOperationTypes.remove: {
for (const tag of tags) {
item?.removeTag(tag);
if (item?.hasTag(tag)) {
hasChanged || (hasChanged = true);
item?.removeTag(tag);
}
}
message = `Remove tag ${tags.join(",")} from item ${item?.getField(
"title",
)}`;
message = hasChanged
? `Remove tag ${tags.join(",")} from item ${item?.getField("title")}`
: "";
break;
}
case ActionOperationTypes.toggle: {
Expand Down

0 comments on commit 59fb70a

Please sign in to comment.