From 5664eb2cfd677f3f7d2cee7f5f24a70776d7c69c Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 19 Sep 2017 10:04:19 +0200 Subject: [PATCH] Widget: Fix crash. Handle the case where a scalar token is not required (jitsi). --- Riot/Utils/Widgets/Widget.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Riot/Utils/Widgets/Widget.m b/Riot/Utils/Widgets/Widget.m index ce3ffbbc4..9fe5e12b1 100644 --- a/Riot/Utils/Widgets/Widget.m +++ b/Riot/Utils/Widgets/Widget.m @@ -48,7 +48,16 @@ withString:mxSession.myUser.avatarUrl ? mxSession.myUser.avatarUrl : @""]; // And their scalar token - _url = [_url stringByAppendingString:[NSString stringWithFormat:@"&scalar_token=%@", [[WidgetManager sharedManager] scalarTokenForMXSession:mxSession]]]; + NSString *scalarToken = [[WidgetManager sharedManager] scalarTokenForMXSession:mxSession]; + if (scalarToken) + { + _url = [_url stringByAppendingString:[NSString stringWithFormat:@"&scalar_token=%@", scalarToken]]; + } + else + { + // Some widget can live without scalar token (ex: Jitsi widget) + NSLog(@"[Widget] Note: There is no scalar token for %@", self); + } } return self;