Skip to content

Commit

Permalink
feat: Update modified in updateIssues and putIssueComment mutators (r…
Browse files Browse the repository at this point in the history
  • Loading branch information
grgbkr authored May 9, 2022
1 parent 953d390 commit 962c921
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion frontend/mutators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Description,
putIssueDescription,
putIssueComment,
Comment,
Issue,
IssueUpdate,
} from "./issue";
Expand All @@ -29,13 +30,15 @@ export const mutators = {
tx: WriteTransaction,
issueUpdates: IssueUpdate[]
): Promise<void> => {
const modified = Date.now();
for (const { id, changes, description } of issueUpdates) {
const issue = await getIssue(tx, id);
if (issue === undefined) {
console.info(`Issue ${id} not found`);
return;
}
const changed = { ...issue, ...changes };
changed.modified = modified;
await putIssue(tx, changed);
if (description) {
await putIssueDescription(tx, id, description);
Expand All @@ -47,5 +50,17 @@ export const mutators = {
await tx.del(issueKey(id));
}
},
putIssueComment,
putIssueComment: async (
tx: WriteTransaction,
comment: Comment
): Promise<void> => {
const issue = await getIssue(tx, comment.issueID);
if (issue === undefined) {
console.info(`Issue ${comment.issueID} not found`);
return;
}
const changed = { ...issue, modified: Date.now() };
await putIssue(tx, changed);
await putIssueComment(tx, comment);
},
};

0 comments on commit 962c921

Please sign in to comment.