Skip to content

Commit

Permalink
- Single item queries: take into account that if items are moved on t…
Browse files Browse the repository at this point in the history
…he server, and they haven't come into view at their new location yet, they may temporarily appear as removed
  • Loading branch information
felix-schwarz committed Jan 31, 2019
1 parent aaaf9be commit 6808431
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ownCloudSDK/Core/OCCore+ItemUpdates.m
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ - (void)performUpdatesForAddedItems:(nullable NSArray<OCItem *> *)addedItems
if (query.queryItem != nil)
{
// Only update queries that have already gone through their complete, initial content update
if (query.state == OCQueryStateIdle)
if ((query.state == OCQueryStateIdle) ||
(query.state == OCQueryStateTargetRemoved)) // An item could appear removed temporarily when it was moved on the server and the item has not yet been seen by the core in its new location
{
OCPath queryItemPath = query.queryItem.path;
OCLocalID queryItemLocalID = query.queryItem.localID;
Expand All @@ -434,10 +435,12 @@ - (void)performUpdatesForAddedItems:(nullable NSArray<OCItem *> *)addedItems
{
if ((resultItem = addedItemList.itemsByPath[queryItemPath]) != nil)
{
query.state = OCQueryStateIdle;
query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem];
}
else if ((resultItem = addedItemList.itemsByLocalID[queryItemLocalID]) != nil)
{
query.state = OCQueryStateIdle;
query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem];
}
}
Expand All @@ -446,10 +449,12 @@ - (void)performUpdatesForAddedItems:(nullable NSArray<OCItem *> *)addedItems
{
if ((resultItem = updatedItemList.itemsByPath[queryItemPath]) != nil)
{
query.state = OCQueryStateIdle;
query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem];
}
else if ((resultItem = updatedItemList.itemsByLocalID[queryItemLocalID]) != nil)
{
query.state = OCQueryStateIdle;
query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem];
}
}
Expand All @@ -458,8 +463,8 @@ - (void)performUpdatesForAddedItems:(nullable NSArray<OCItem *> *)addedItems
{
if ((removedItemList.itemsByPath[queryItemPath] != nil) || (removedItemList.itemsByLocalID[queryItemLocalID] != nil))
{
query.fullQueryResults = [NSMutableArray new];
query.state = OCQueryStateTargetRemoved;
query.fullQueryResults = [NSMutableArray new];
}
}
}
Expand Down

0 comments on commit 6808431

Please sign in to comment.