Skip to content

Commit

Permalink
litecore update to 170 fixes (#2970)
Browse files Browse the repository at this point in the history
* litecore update to 170 fixes
  • Loading branch information
jayahariv committed Jun 22, 2022
1 parent cdea697 commit cc7daa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions Objective-C/CBLDatabase.mm
Expand Up @@ -1122,13 +1122,12 @@ - (void) postDatabaseChanged {
const uint32_t kMaxChanges = 100u;
C4DatabaseChange changes[kMaxChanges];
bool external = false;
uint32_t nChanges = 0u;
C4CollectionObservation obs = {};
NSMutableArray* docIDs = [NSMutableArray new];
do {
// Read changes in batches of kMaxChanges:
bool newExternal;
nChanges = c4dbobs_getChanges(_dbObs, changes, kMaxChanges, &newExternal);
if (nChanges == 0 || external != newExternal || docIDs.count > 1000) {
obs = c4dbobs_getChanges(_dbObs, changes, kMaxChanges);
if (obs.numChanges == 0 || external != obs.external || docIDs.count > 1000) {
if(docIDs.count > 0) {
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
#pragma clang diagnostic push
Expand All @@ -1137,19 +1136,19 @@ - (void) postDatabaseChanged {
[_dbChangeNotifier postChange:
[[CBLDatabaseChange alloc] initWithDatabase: self
documentIDs: docIDs
isExternal: external] ];
isExternal: external]];
#pragma clang diagnostic pop
docIDs = [NSMutableArray new];
}
}

external = newExternal;
for(uint32_t i = 0; i < nChanges; i++) {
external = obs.external;
for(uint32_t i = 0; i < obs.numChanges; i++) {
NSString *docID =slice2string(changes[i].docID);
[docIDs addObject: docID];
}
c4dbobs_releaseChanges(changes, nChanges);
} while(nChanges > 0);
c4dbobs_releaseChanges(changes, obs.numChanges);
} while(obs.numChanges > 0);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Objective-C/Internal/CBLDocumentChangeNotifier.mm
Expand Up @@ -41,8 +41,8 @@ - (instancetype) initWithDatabase: (CBLDatabase*)db
return self;
}

static void docObserverCallback(C4DocumentObserver* obs, C4Slice docID, C4SequenceNumber seq,
void *context)
static void docObserverCallback(C4DocumentObserver* obs, C4Collection* collection,
C4Slice docID, C4SequenceNumber seq, void *context)
{
[(__bridge CBLDocumentChangeNotifier*)context postChange];
}
Expand Down

0 comments on commit cc7daa3

Please sign in to comment.