fix(ios) avoid getting duplicated SDK events

UIView has 2 designated initializers: initWithFrame and initWithCoder,
which means either of them is going to be called, whatever the
constructor.

THus overriding init will cause creating new (and unnecessary)
observers.

Ref: https://community.jitsi.org/t/duplicate-delegate-calls/121051/6
Fixes: https://github.com/jitsi/jitsi-meet/issues/12892
This commit is contained in:
Saúl Ibarra Corretgé 2023-02-10 16:19:33 +01:00 committed by Saúl Ibarra Corretgé
parent 45aa53b1a6
commit 46c6d1057d
1 changed files with 4 additions and 13 deletions

View File

@ -40,19 +40,10 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled";
#pragma mark Initializers #pragma mark Initializers
- (instancetype)init {
self = [super init];
if (self) {
[self initWithXXX];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder]; self = [super initWithCoder:coder];
if (self) { if (self) {
[self initWithXXX]; [self doInitialize];
} }
return self; return self;
@ -61,7 +52,7 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled";
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
[self initWithXXX]; [self doInitialize];
} }
return self; return self;
@ -71,9 +62,9 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled";
* Internal initialization: * Internal initialization:
* *
* - sets the background color * - sets the background color
* - initializes the external API scope * - registers necessary observers
*/ */
- (void)initWithXXX { - (void)doInitialize {
// Set a background color which is in accord with the JavaScript and Android // Set a background color which is in accord with the JavaScript and Android
// parts of the application and causes less perceived visual flicker than // parts of the application and causes less perceived visual flicker than
// the default background color. // the default background color.