@@ -21,7 +21,7 @@ class CometChatCallListItem: UITableViewCell {
2121 @IBOutlet weak var time : UILabel !
2222
2323 // MARK: - Declaration of Variables
24-
24+
2525 var currentUser : User ?
2626 var currentGroup : Group ?
2727
@@ -37,8 +37,8 @@ class CometChatCallListItem: UITableViewCell {
3737 if let user = call. callReceiver as? User {
3838 self . currentUser = user
3939 self . name. text = user. name
40- avatar . set ( image : user . avatar ?? " " , with : user. name ?? " " )
41-
40+ /// Set the image for the user.
41+ avatar . set ( image : user . avatar , with : user . name )
4242 }
4343 callStatus. text = " OUTGOING_AUDIO_CALL " . localized ( )
4444 callStatusIcon. image = UIImage ( named: " outgoing-audio-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -54,7 +54,8 @@ class CometChatCallListItem: UITableViewCell {
5454 if let user = call. callInitiator as? User {
5555 self . currentUser = user
5656 self . name. text = user. name
57- avatar. set ( image: user. avatar ?? " " , with: user. name ?? " " )
57+ /// Set the avatar for the user.
58+ avatar. set ( image: user. avatar, with: user. name)
5859 }
5960 callStatus. text = " INCOMING_AUDIO_CALL " . localized ( )
6061 callStatusIcon. image = UIImage ( named: " incoming-audio-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -70,7 +71,8 @@ class CometChatCallListItem: UITableViewCell {
7071 if let group = call. callReceiver as? Group {
7172 self . currentGroup = group
7273 self . name. text = group. name
73- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
74+ /// Set the avatar for the group.
75+ avatar. set ( image: group. icon, with: group. name)
7476 }
7577 callStatus. text = " INCOMING_AUDIO_CALL " . localized ( )
7678 callStatusIcon. image = UIImage ( named: " incoming-audio-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -86,7 +88,8 @@ class CometChatCallListItem: UITableViewCell {
8688 if let group = call. callReceiver as? Group {
8789 self . currentGroup = group
8890 self . name. text = group. name
89- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
91+ /// Set the avatar for the group.
92+ avatar. set ( image: group. icon, with: group. name)
9093 }
9194 callStatus. text = " OUTGOING_AUDIO_CALL " . localized ( )
9295 callStatusIcon. image = UIImage ( named: " outgoing-audio-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -101,7 +104,8 @@ class CometChatCallListItem: UITableViewCell {
101104 if let user = call. callReceiver as? User {
102105 self . currentUser = user
103106 self . name. text = user. name
104- avatar. set ( image: user. avatar ?? " " , with: user. name ?? " " )
107+ /// Set the avatar for the user.
108+ avatar. set ( image: user. name, with: user. name)
105109
106110 }
107111 callStatus. text = " OUTGOING_VIDEO_CALL " . localized ( )
@@ -116,8 +120,8 @@ class CometChatCallListItem: UITableViewCell {
116120 if let user = call. callInitiator as? User {
117121 self . currentUser = user
118122 self . name. text = user. name
119- avatar . set ( image : user . avatar ?? " " , with : user. name ?? " " )
120-
123+ /// Set the avatar for the user.
124+ avatar . set ( image : user . name , with : user . name )
121125 }
122126 callStatus. text = " INCOMING_VIDEO_CALL " . localized ( )
123127 callStatusIcon. image = UIImage ( named: " incoming-video-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -131,7 +135,8 @@ class CometChatCallListItem: UITableViewCell {
131135 if let group = call. callReceiver as? Group {
132136 self . currentGroup = group
133137 self . name. text = group. name
134- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
138+ /// Set the avatar for the group.
139+ avatar. set ( image: group. icon, with: group. name)
135140 }
136141 callStatus. text = " OUTGOING_VIDEO_CALL " . localized ( )
137142 callStatusIcon. image = UIImage ( named: " outgoing-video-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -145,7 +150,8 @@ class CometChatCallListItem: UITableViewCell {
145150 if let group = call. callReceiver as? Group {
146151 self . currentGroup = group
147152 self . name. text = group. name
148- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
153+ /// Set the avatar for the group.
154+ avatar. set ( image: group. icon, with: group. name)
149155 }
150156 callStatus. text = " INCOMING_VIDEO_CALL " . localized ( )
151157 callStatusIcon. image = UIImage ( named: " incoming-video-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -159,7 +165,8 @@ class CometChatCallListItem: UITableViewCell {
159165 if let user = call. callReceiver as? User {
160166 self . currentUser = user
161167 self . name. text = user. name
162- avatar. set ( image: user. avatar ?? " " , with: user. name ?? " " )
168+ /// Set the avatar for the user.
169+ avatar. set ( image: user. avatar, with: user. name)
163170 }
164171 callStatus. text = " UNANSWERED_AUDIO_CALL " . localized ( )
165172 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -173,8 +180,8 @@ class CometChatCallListItem: UITableViewCell {
173180 if let user = call. callInitiator as? User {
174181 self . currentUser = user
175182 self . name. text = user. name
176- avatar . set ( image : user . avatar ?? " " , with : user. name ?? " " )
177-
183+ /// Set the avatar for the user.
184+ avatar . set ( image : user . avatar , with : user . name )
178185 }
179186 callStatus. text = " MISSED_CALL " . localized ( )
180187 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -188,7 +195,8 @@ class CometChatCallListItem: UITableViewCell {
188195 if let group = call. callReceiver as? Group {
189196 self . currentGroup = group
190197 self . name. text = group. name
191- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
198+ /// Set the avatar for the group.
199+ avatar. set ( image: group. icon, with: group. name)
192200 }
193201 callStatus. text = " UNANSWERED_AUDIO_CALL " . localized ( )
194202 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -202,7 +210,8 @@ class CometChatCallListItem: UITableViewCell {
202210 if let group = call. callReceiver as? Group {
203211 self . currentGroup = group
204212 self . name. text = group. name
205- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
213+ /// Set the avatar for the group.
214+ avatar. set ( image: group. icon, with: group. name)
206215 }
207216 callStatus. text = " MISSED_CALL " . localized ( )
208217 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -216,7 +225,8 @@ class CometChatCallListItem: UITableViewCell {
216225 if let user = call. callReceiver as? User {
217226 self . currentUser = user
218227 self . name. text = user. name
219- avatar. set ( image: user. avatar ?? " " , with: user. name ?? " " )
228+ /// Set the avatar for the user.
229+ avatar. set ( image: user. avatar, with: user. name)
220230 }
221231 callStatus. text = " UNANSWERED_VIDEO_CALL " . localized ( )
222232 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -230,8 +240,8 @@ class CometChatCallListItem: UITableViewCell {
230240 if let user = call. callInitiator as? User {
231241 self . currentUser = user
232242 self . name. text = user. name
233- avatar . set ( image : user . avatar ?? " " , with : user. name ?? " " )
234-
243+ /// Set the avatar for the user.
244+ avatar . set ( image : user . avatar , with : user . name )
235245 }
236246 callStatus. text = " MISSED_CALL " . localized ( )
237247 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -245,7 +255,8 @@ class CometChatCallListItem: UITableViewCell {
245255 if let group = call. callReceiver as? Group {
246256 self . currentGroup = group
247257 self . name. text = group. name
248- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
258+ /// Set the avatar for the group.
259+ avatar. set ( image: group. icon, with: group. name)
249260 }
250261 callStatus. text = " UNANSWERED_VIDEO_CALL " . localized ( )
251262 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -259,7 +270,8 @@ class CometChatCallListItem: UITableViewCell {
259270 if let group = call. callReceiver as? Group {
260271 self . currentGroup = group
261272 self . name. text = group. name
262- avatar. set ( image: group. icon ?? " " , with: group. name ?? " " )
273+ /// Set the avatar for the group.
274+ avatar. set ( image: group. icon, with: group. name)
263275 }
264276 callStatus. text = " MISSED_CALL " . localized ( )
265277 callStatusIcon. image = UIImage ( named: " end-call " , in: UIKitSettings . bundle, compatibleWith: nil )
@@ -296,6 +308,12 @@ class CometChatCallListItem: UITableViewCell {
296308 // Configure the view for the selected state
297309 }
298310
311+ override func prepareForReuse( ) {
312+ super. prepareForReuse ( )
313+ // Cancel Image Request
314+ avatar. cancel ( )
315+ }
316+
299317}
300318
301319/* ----------------------------------------------------------------------------------------- */
0 commit comments