18
18
package com.infomaniak.mail.data.models.calendar
19
19
20
20
import com.infomaniak.lib.core.utils.Utils
21
+ import com.infomaniak.mail.data.models.calendar.CalendarEvent.CalendarEventStatus
21
22
import com.infomaniak.mail.utils.extensions.isUserIn
22
23
import io.realm.kotlin.types.EmbeddedRealmObject
23
24
import kotlinx.serialization.SerialName
@@ -39,12 +40,10 @@ class CalendarEventResponse() : EmbeddedRealmObject {
39
40
40
41
constructor (
41
42
userStoredEvent: CalendarEvent ? ,
42
- isUserStoredEventDeleted: Boolean ,
43
43
attachmentEvent: CalendarEvent ? ,
44
44
attachmentEventMethod: String? ,
45
45
) : this () {
46
46
this .userStoredEvent = userStoredEvent
47
- this .isUserStoredEventDeleted = isUserStoredEventDeleted
48
47
this .attachmentEvent = attachmentEvent
49
48
this ._attachmentEventMethod = attachmentEventMethod
50
49
}
@@ -54,7 +53,7 @@ class CalendarEventResponse() : EmbeddedRealmObject {
54
53
55
54
val calendarEvent get() = userStoredEvent ? : attachmentEvent
56
55
57
- val isCanceled get() = isUserStoredEventDeleted || attachmentEventMethod == AttachmentEventMethod . CANCEL
56
+ val isCanceled get() = calendarEvent?.status == CalendarEventStatus . CANCELLED
58
57
59
58
fun isReplyAuthorized (): Boolean {
60
59
return (attachmentEventMethod == null || attachmentEventMethod == AttachmentEventMethod .REQUEST )
@@ -69,7 +68,6 @@ class CalendarEventResponse() : EmbeddedRealmObject {
69
68
fun everythingButAttendeesIsTheSame (other : CalendarEventResponse ? ): Boolean {
70
69
if (other == null ) return false
71
70
72
- if (isUserStoredEventDeleted != other.isUserStoredEventDeleted) return false
73
71
if (_attachmentEventMethod != other._attachmentEventMethod ) return false
74
72
75
73
val c1 = calendarEvent
@@ -88,15 +86,13 @@ class CalendarEventResponse() : EmbeddedRealmObject {
88
86
other as CalendarEventResponse
89
87
90
88
if (userStoredEvent != other.userStoredEvent) return false
91
- if (isUserStoredEventDeleted != other.isUserStoredEventDeleted) return false
92
89
if (attachmentEvent != other.attachmentEvent) return false
93
90
94
91
return _attachmentEventMethod == other._attachmentEventMethod
95
92
}
96
93
97
94
override fun hashCode (): Int {
98
95
var result = userStoredEvent?.hashCode() ? : 0
99
- result = 31 * result + isUserStoredEventDeleted.hashCode()
100
96
result = 31 * result + (attachmentEvent?.hashCode() ? : 0 )
101
97
result = 31 * result + (_attachmentEventMethod ?.hashCode() ? : 0 )
102
98
0 commit comments