File tree Expand file tree Collapse file tree 5 files changed +13
-21
lines changed
Expand file tree Collapse file tree 5 files changed +13
-21
lines changed Original file line number Diff line number Diff line change @@ -30,22 +30,17 @@ func (op *AddCommentOperation) Id() entity.Id {
3030func (op * AddCommentOperation ) Apply (snapshot * Snapshot ) {
3131 snapshot .addActor (op .Author_ )
3232 snapshot .addParticipant (op .Author_ )
33-
3433 comment := Comment {
3534 id : entity .CombineIds (snapshot .Id (), op .Id ()),
3635 Message : op .Message ,
3736 Author : op .Author_ ,
3837 Files : op .Files ,
3938 UnixTime : timestamp .Timestamp (op .UnixTime ),
4039 }
41-
4240 snapshot .appendComment (comment )
43-
44- item := & AddCommentTimelineItem {
41+ snapshot .appendTimelineItem (& AddCommentTimelineItem {
4542 CommentTimelineItem : NewCommentTimelineItem (comment ),
46- }
47-
48- snapshot .timeline = append (snapshot .timeline , item )
43+ })
4944}
5045
5146func (op * AddCommentOperation ) GetFiles () []repository.Hash {
Original file line number Diff line number Diff line change @@ -38,15 +38,13 @@ func (op *LabelChangeOperation) Apply(snapshot *Snapshot) {
3838 snapshot .removeLabel (label )
3939 }
4040
41- item := & LabelChangeTimelineItem {
41+ snapshot . appendTimelineItem ( & LabelChangeTimelineItem {
4242 id : op .Id (),
4343 Author : op .Author_ ,
4444 UnixTime : timestamp .Timestamp (op .UnixTime ),
4545 Added : op .Added ,
4646 Removed : op .Removed ,
47- }
48-
49- snapshot .timeline = append (snapshot .timeline , item )
47+ })
5048}
5149
5250func (op * LabelChangeOperation ) Validate () error {
Original file line number Diff line number Diff line change @@ -25,15 +25,12 @@ func (op *SetStatusOperation) Id() entity.Id {
2525func (op * SetStatusOperation ) Apply (snapshot * Snapshot ) {
2626 snapshot .setStatusTo (op .Status )
2727 snapshot .addActor (op .Author_ )
28-
29- item := & SetStatusTimelineItem {
28+ snapshot .appendTimelineItem (& SetStatusTimelineItem {
3029 id : op .Id (),
3130 Author : op .Author_ ,
3231 UnixTime : timestamp .Timestamp (op .UnixTime ),
3332 Status : op .Status ,
34- }
35-
36- snapshot .timeline = append (snapshot .timeline , item )
33+ })
3734}
3835
3936func (op * SetStatusOperation ) Validate () error {
Original file line number Diff line number Diff line change @@ -27,16 +27,13 @@ func (op *SetTitleOperation) Id() entity.Id {
2727func (op * SetTitleOperation ) Apply (snapshot * Snapshot ) {
2828 snapshot .changeTitleTo (op .Title )
2929 snapshot .addActor (op .Author_ )
30-
31- item := & SetTitleTimelineItem {
30+ snapshot .appendTimelineItem (& SetTitleTimelineItem {
3231 id : op .Id (),
3332 Author : op .Author_ ,
3433 UnixTime : timestamp .Timestamp (op .UnixTime ),
3534 Title : op .Title ,
3635 Was : op .Was ,
37- }
38-
39- snapshot .timeline = append (snapshot .timeline , item )
36+ })
4037}
4138
4239func (op * SetTitleOperation ) Validate () error {
Original file line number Diff line number Diff line change @@ -165,6 +165,11 @@ func (snap *Snapshot) addParticipant(participant identity.Interface) {
165165 snap .participants = append (snap .participants , participant )
166166}
167167
168+ // Append the supplied timelineitem to the snapshots timeline
169+ func (snap * Snapshot ) appendTimelineItem (item TimelineItem ) {
170+ snap .timeline = append (snap .timeline , item )
171+ }
172+
168173// HasParticipant return true if the id is a participant
169174func (snap * Snapshot ) HasParticipant (id entity.Id ) bool {
170175 for _ , p := range snap .participants {
You can’t perform that action at this time.
0 commit comments