Skip to content

Commit

Permalink
add debugDescriptionLines for new updater
Browse files Browse the repository at this point in the history
Summary: The current `IGListAdapterUpdater` implements `-debugDescriptionLines` which is used by `IGListDebugger` to dump information about all the apaters, so lets also implement it for `IGListExperimentalAdapterUpdater`.

Reviewed By: lorixx

Differential Revision: D25884781

fbshipit-source-id: 86b227258f033f0079058af04915171d6a149241
  • Loading branch information
maxolls authored and facebook-github-bot committed Jan 22, 2021
1 parent 329a4d3 commit 3b47aa2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <IGListKit/IGListExperimentalAdapterUpdater.h>

@interface IGListExperimentalAdapterUpdater (DebugDescription)

- (NSArray<NSString *> *)debugDescriptionLines;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "IGListExperimentalAdapterUpdater+DebugDescription.h"

#import "IGListBatchUpdateData+DebugDescription.h"
#import "IGListDebuggingUtilities.h"
#import "IGListExperimentalAdapterUpdaterInternal.h"
#import "IGListUpdateTransactable.h"

@implementation IGListExperimentalAdapterUpdater (DebugDescription)

- (NSArray<NSString *> *)debugDescriptionLines {
NSMutableArray *debug = [NSMutableArray new];
#if defined(IGLK_DEBUG_DESCRIPTION_ENABLED) && IGLK_DEBUG_DESCRIPTION_ENABLED
[debug addObject:@"Options:"];
NSArray<NSString *> *options = @[
[NSString stringWithFormat:@"sectionMovesAsDeletesInserts: %@", IGListDebugBOOL(self.sectionMovesAsDeletesInserts)],
[NSString stringWithFormat:@"singleItemSectionUpdates: %@", IGListDebugBOOL(self.singleItemSectionUpdates)],
[NSString stringWithFormat:@"preferItemReloadsForSectionReloads: %@", IGListDebugBOOL(self.preferItemReloadsForSectionReloads)],
[NSString stringWithFormat:@"allowsBackgroundReloading: %@", IGListDebugBOOL(self.allowsBackgroundReloading)],
[NSString stringWithFormat:@"allowsReloadingOnTooManyUpdates: %@", IGListDebugBOOL(self.allowsReloadingOnTooManyUpdates)]
];
[debug addObjectsFromArray:IGListDebugIndentedLines(options)];

const IGListBatchUpdateState state = self.transaction ? [self.transaction state] : IGListBatchUpdateStateIdle;

NSString *stateString;
switch (state) {
case IGListBatchUpdateStateIdle:
stateString = @"Idle";
break;
case IGListBatchUpdateStateQueuedBatchUpdate:
stateString = @"Queued batch update";
break;
case IGListBatchUpdateStateExecutedBatchUpdateBlock:
stateString = @"Executed batch update block";
break;
case IGListBatchUpdateStateExecutingBatchUpdateBlock:
stateString = @"Executing batch update block";
break;
}
[debug addObject:[NSString stringWithFormat:@"State: %@", stateString]];

#endif // #if IGLK_DEBUG_DESCRIPTION_ENABLED
return debug;
}

@end

0 comments on commit 3b47aa2

Please sign in to comment.