Skip to content
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

Merged
merged 9 commits into from
Jul 12, 2024
Merged

[MC-1739] PE File Variables #343

merged 9 commits into from
Jul 12, 2024

Conversation

nishant-clevertap
Copy link
Contributor

@nishant-clevertap nishant-clevertap commented Jun 25, 2024

  • Added support for File in PE Variables
  • Adds new CleverTap APIs onVariablesChangedAndNoDownloadsPending and onceVariablesChangedAndNoDownloadsPending.
  • Adds new fileIsReady callback in CTVarDelegate when file is downloaded.
  • Added unit tests for File type variables

@nishant-clevertap nishant-clevertap self-assigned this Jun 25, 2024
@nishant-clevertap nishant-clevertap changed the base branch from file_downloading to develop July 9, 2024 07:25
- 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.
@nzagorchev nzagorchev force-pushed the pe_file_type_variables branch from 2ff84c3 to e7fa620 Compare July 9, 2024 09:17
Copy link
Contributor

@nzagorchev nzagorchev left a 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;
Copy link
Contributor

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]) {
Copy link
Contributor

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]) {
Copy link
Contributor

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]) {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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

@nzagorchev nzagorchev merged commit fe45d85 into develop Jul 12, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants