-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MC-1739] PE File Variables #343
Conversation
- Adds new CleverTap APIs onVariablesChangedAndNoDownloadsPending and onceVariablesChangedAndNoDownloadsPending. - Adds new fileIsReady callback in CTVarDelegate when file is downloaded.
- Updated logic to call fileIsReady when delegate is set.
- Update fileURL value also when file value has changed.
2ff84c3
to
e7fa620
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onFileIsReady
callback block needs to be added.
File needs to be downloaded ad-hoc if the variable was registered after the initial fetch response is handled and applyDiffs
has already applied the changes.
/** | ||
* Called when the file is downloaded and ready. | ||
*/ | ||
- (void)fileIsReady:(CTVar *)var; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add onFileReady as a callback as well, similar to onValueChanged
NSMutableArray<NSString *> *retryURLs; | ||
// Call fileIsReady for variables whose files are downloaded. | ||
for (NSString *key in status.allKeys) { | ||
if (status[key]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the status bool value
[self setHasPendingDownloads:NO]; | ||
for (NSString *key in status.allKeys) { | ||
@synchronized (self) { | ||
if (status[key]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the status bool value
@@ -84,6 +93,11 @@ - (void)update { | |||
|
|||
if (![_value isEqual:oldValue]) { | |||
_hasChanged = YES; | |||
|
|||
// Update _fileURL with new value if it has changed. | |||
if ([_kind isEqualToString:CT_KIND_FILE]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File needs to be downloaded ad-hoc if the variable is registered after the initial fetch and applyDiffs
XCTAssertEqualObjects(expValue1, var1.fileValue); | ||
} | ||
|
||
- (void)removeFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method can be moved to helper and reused
XCTAssertEqualObjects(expValue, varFromDelegate.value); | ||
} | ||
|
||
- (void)removeFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method can be moved to helper and reused
XCTAssertEqualObjects(@1, var1.value); | ||
} | ||
|
||
- (void)removeFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method can be moved to helper and reused
onVariablesChangedAndNoDownloadsPending
andonceVariablesChangedAndNoDownloadsPending
.fileIsReady
callback in CTVarDelegate when file is downloaded.