aboutsummaryrefslogtreecommitdiffstats
path: root/entities/bug/op_edit_comment.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-08-23 15:01:36 +0200
committerGitHub <noreply@github.com>2022-08-23 15:01:36 +0200
commit5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (patch)
treee5382a09a45098672b6d60397eac201617fdd6ec /entities/bug/op_edit_comment.go
parent81fd7a5d8b6443e65c861f00a7387c0a3c926c66 (diff)
parent6ed4b8b7a1185ad278eb2e40b32e859f828233d9 (diff)
downloadgit-bug-5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f.tar.gz
Merge pull request #664 from MichaelMure/combined-id-rework
bug: have a type for combined ids, fix #653
Diffstat (limited to 'entities/bug/op_edit_comment.go')
-rw-r--r--entities/bug/op_edit_comment.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/entities/bug/op_edit_comment.go b/entities/bug/op_edit_comment.go
index 41079f45..b0897b0a 100644
--- a/entities/bug/op_edit_comment.go
+++ b/entities/bug/op_edit_comment.go
@@ -33,12 +33,12 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) {
// Todo: currently any message can be edited, even by a different author
// crypto signature are needed.
- // Recreate the Comment Id to match on
- commentId := entity.CombineIds(snapshot.Id(), op.Target)
+ // Recreate the combined Id to match on
+ combinedId := entity.CombineIds(snapshot.Id(), op.Target)
var target TimelineItem
for i, item := range snapshot.Timeline {
- if item.Id() == commentId {
+ if item.CombinedId() == combinedId {
target = snapshot.Timeline[i]
break
}
@@ -50,10 +50,11 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) {
}
comment := Comment{
- id: commentId,
- Message: op.Message,
- Files: op.Files,
- UnixTime: timestamp.Timestamp(op.UnixTime),
+ combinedId: combinedId,
+ targetId: op.Target,
+ Message: op.Message,
+ Files: op.Files,
+ unixTime: timestamp.Timestamp(op.UnixTime),
}
switch target := target.(type) {
@@ -72,7 +73,7 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) {
// Updating the corresponding comment
for i := range snapshot.Comments {
- if snapshot.Comments[i].Id() == commentId {
+ if snapshot.Comments[i].CombinedId() == combinedId {
snapshot.Comments[i].Message = op.Message
snapshot.Comments[i].Files = op.Files
break