]> git.giacomolli.uk - onechat/blobdiff - turn_test.go
Link WhatsApp with a pairing code
[onechat] / turn_test.go
index 928ac334b9dcce7d38c0b357517de80c3597f8c6..b0417cfc7469781f3460fd021aeec49b4ad8f6e7 100644 (file)
@@ -308,16 +308,21 @@ func (r *TurnEventRecorder) Count(kind string) int {
 
 // Last returns the text of the last event of kind.
 func (r *TurnEventRecorder) Last(kind string) string {
 
 // Last returns the text of the last event of kind.
 func (r *TurnEventRecorder) Last(kind string) string {
+       return r.LastEvent(kind).Text
+}
+
+// LastEvent returns the last event of kind.
+func (r *TurnEventRecorder) LastEvent(kind string) Event {
        r.mutex.Lock()
        defer r.mutex.Unlock()
 
        for n := len(r.events) - 1; n >= 0; n-- {
                if r.events[n].Kind == kind {
        r.mutex.Lock()
        defer r.mutex.Unlock()
 
        for n := len(r.events) - 1; n >= 0; n-- {
                if r.events[n].Kind == kind {
-                       return r.events[n].Text
+                       return r.events[n]
                }
        }
 
                }
        }
 
-       return ""
+       return Event{}
 }
 
 func (r *TurnEventRecorder) Add(event Event) {
 }
 
 func (r *TurnEventRecorder) Add(event Event) {