Skip to content

Commit

Permalink
[Onboarding] Fixes blank gene images.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfurrow committed Oct 17, 2016
1 parent 17bc6f9 commit 052ca51
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Artsy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@
5E6A16931C98A914004DB29B /* LiveAuctionStateManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E6A16921C98A914004DB29B /* LiveAuctionStateManagerSpec.swift */; };
5E6BA6E91C56B5D700B942C1 /* CircularCancelButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5E6BA6E71C56B5D700B942C1 /* CircularCancelButton@2x.png */; };
5E6BA6EA1C56B5D700B942C1 /* CircularCancelButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 5E6BA6E81C56B5D700B942C1 /* CircularCancelButton.png */; };
5E6CBB011DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E6CBB001DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m */; };
5E6CBB031DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E6CBB021DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m */; };
5E71AFC7195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E71AFC6195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m */; };
5E73C93A1C6933FA00496C7C /* AuctionTitleViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E73C9391C6933FA00496C7C /* AuctionTitleViewTests.swift */; };
5E7598061D9D92F60084AAEC /* LiveAuctionLotBidHistoryGestureControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7598041D9D92F20084AAEC /* LiveAuctionLotBidHistoryGestureControllerTests.swift */; };
Expand Down Expand Up @@ -1309,6 +1311,9 @@
5E6A16921C98A914004DB29B /* LiveAuctionStateManagerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LiveAuctionStateManagerSpec.swift; path = ../../Artsy/View_Controllers/Live_Auctions/LiveAuctionStateManagerSpec.swift; sourceTree = "<group>"; };
5E6BA6E71C56B5D700B942C1 /* CircularCancelButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "CircularCancelButton@2x.png"; sourceTree = "<group>"; };
5E6BA6E81C56B5D700B942C1 /* CircularCancelButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CircularCancelButton.png; sourceTree = "<group>"; };
5E6CBAFF1DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AROnboardingPersonalizationGeneImageStateReconciler.h; sourceTree = "<group>"; };
5E6CBB001DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AROnboardingPersonalizationGeneImageStateReconciler.m; sourceTree = "<group>"; };
5E6CBB021DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AROnboardingPersonalizationGeneImageStateReconcilerTests.m; sourceTree = "<group>"; };
5E71AF231912826B008B1426 /* ARPersonalizeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARPersonalizeViewController.h; sourceTree = "<group>"; };
5E71AFC6195C64C1000F6325 /* ARFairGuideContainerViewControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARFairGuideContainerViewControllerTests.m; sourceTree = "<group>"; };
5E73C9391C6933FA00496C7C /* AuctionTitleViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AuctionTitleViewTests.swift; path = Auctions/AuctionTitleViewTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2697,6 +2702,7 @@
3CB97D8E1887099E008C44FE /* ARLoginViewControllerTests.m */,
3CF144B718E9E00400B1A764 /* ARSignUpSplashViewControllerTests.m */,
60D7FB721AC35F5600F5043A /* ARPersonalizeWebViewControllerTests.m */,
5E6CBB021DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m */,
);
name = "Login and Onboarding";
path = Login_and_Onboarding;
Expand Down Expand Up @@ -3280,6 +3286,8 @@
1CC9EB961CC0EDBE00A74E3C /* AROnboardingPersonalizeTableViewController.m */,
CB206F6F17C3FA8F00A4FDC4 /* ARPriceRangeViewController.h */,
CB206F7017C3FA8F00A4FDC4 /* ARPriceRangeViewController.m */,
5E6CBAFF1DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.h */,
5E6CBB001DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m */,
);
name = "Onboarding Personalization";
path = "5-_Onboarding_Personalization";
Expand Down Expand Up @@ -5670,6 +5678,7 @@
607E2E8717C8E87E00396120 /* ARArtworkPreviewImageView.m in Sources */,
E61446AC195A1CDC00BFB7C3 /* ARArtistFavoritesNetworkModel.m in Sources */,
3C6CB61018ABFB8D008DFE3B /* ARRelatedArtistsViewController.m in Sources */,
5E6CBB011DB54A5500988CDF /* AROnboardingPersonalizationGeneImageStateReconciler.m in Sources */,
3C35CC7B189FF05E00E3D8DE /* OrderedSet.m in Sources */,
5E5B841F1C52DEC40005CBC7 /* AuctionOrdering.swift in Sources */,
60903CC4175CE21A002AB800 /* AROptions.m in Sources */,
Expand Down Expand Up @@ -5975,6 +5984,7 @@
3CBB03A8192BA94C00689F89 /* ARFairArtistViewControllerTests.m in Sources */,
3CF144B618E4802400B1A764 /* ARSystemTimeTests.m in Sources */,
60D7FB731AC35F5600F5043A /* ARPersonalizeWebViewControllerTests.m in Sources */,
5E6CBB031DB54BC000988CDF /* AROnboardingPersonalizationGeneImageStateReconcilerTests.m in Sources */,
5E7598061D9D92F60084AAEC /* LiveAuctionLotBidHistoryGestureControllerTests.swift in Sources */,
E6F111A018A2A7CB00D33C3E /* ARBrowseFeaturedLinksCollectionViewControllerTests.m in Sources */,
3C7A7FA718C6EDAB00E8D336 /* ArtworkTests.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import <Foundation/Foundation.h>

@class Gene;


@interface AROnboardingPersonalizationGeneImageStateReconciler : NSObject

- (NSURL *)imageURLForGene:(Gene *)gene atIndexPath:(NSIndexPath *)indexPath;

- (void)addReplacedGene:(NSIndexPath *)indexPath;
- (void)reset;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#import "AROnboardingPersonalizationGeneImageStateReconciler.h"
#import "Gene.h"


@interface AROnboardingPersonalizationGeneImageStateReconciler ()

@property (nonatomic, strong) NSMutableSet *replacedGenes;

@end


@implementation AROnboardingPersonalizationGeneImageStateReconciler

- (instancetype)init
{
self = [super init];
if (!self) {
return nil;
}

_replacedGenes = [NSMutableSet set];

return self;
}

- (NSURL *)imageURLForGene:(Gene *)gene atIndexPath:(NSIndexPath *)indexPath
{
if ([self.replacedGenes containsObject:indexPath]) {
return gene.smallImageURL;
} else {
return gene.onboardingImageURL;
}
}

- (void)addReplacedGene:(NSIndexPath *)indexPath
{
[self.replacedGenes addObject:indexPath];
}

- (void)reset
{
[self.replacedGenes removeAllObjects];
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "Gene.h"
#import "ARFollowable.h"
#import "UIImageView+AsyncImageLoading.h"
#import "AROnboardingPersonalizationGeneImageStateReconciler.h"

#import <Artsy_UIFonts/UIFont+ArtsyFonts.h>
#import <FLKAutoLayout/UIView+FLKAutoLayout.h>
Expand All @@ -14,6 +15,7 @@
@interface AROnboardingPersonalizeTableViewController ()

@property (nonatomic, assign) BOOL shouldAnimate;
@property (nonatomic, strong) AROnboardingPersonalizationGeneImageStateReconciler *geneImageReconciler;
@property (nonatomic, strong) NSIndexPath *selectedRowToReplace;
@property (nonatomic, strong, readwrite) NSMutableArray *searchResults;
@property (nonatomic, strong) UILabel *noResultsLabel;
Expand All @@ -27,6 +29,7 @@ - (instancetype)init
{
self = [super init];
if (self) {
_geneImageReconciler = [AROnboardingPersonalizationGeneImageStateReconciler new];
_searchResults = [NSMutableArray array];
}

Expand Down Expand Up @@ -63,9 +66,11 @@ - (void)updateTableContentsFor:(NSArray *)searchResults
[self.searchResults removeObjectAtIndex:self.tableView.indexPathForSelectedRow.row];
}
self.selectedRowToReplace = self.tableView.indexPathForSelectedRow;
[self.geneImageReconciler addReplacedGene:self.selectedRowToReplace];

break;
case ARSearchResultsReplaceAll:
[self.geneImageReconciler reset];
self.searchResults = searchResults.mutableCopy;
break;
default:
Expand Down Expand Up @@ -219,7 +224,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
} else if ([result isKindOfClass:[Gene class]]) {
Gene *gene = (Gene *)result;
cell.title.text = gene.name;
NSURL *geneImageURL = self.contentDisplayMode == ARTableViewContentDisplayModePlaceholder ? gene.onboardingImageURL : gene.smallImageURL;

NSURL *geneImageURL;
if (self.contentDisplayMode == ARTableViewContentDisplayModePlaceholder) {
geneImageURL = [self.geneImageReconciler imageURLForGene:gene atIndexPath:indexPath];
} else {
geneImageURL = gene.smallImageURL;
}
[cell.thumbnail ar_setImageWithURL:geneImageURL];
}
cell.thumbnail.backgroundColor = [UIColor purpleColor];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#import "AROnboardingPersonalizationGeneImageStateReconciler.h"

SpecBegin(AROnboardingPersonalizationGeneImageStateReconciler);

__block AROnboardingPersonalizationGeneImageStateReconciler *subject;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
Gene *gene = [Gene modelWithJSON:@{
@"id" : @"some_gene",
@"image_url" : @"http://example.com/:version.jpg",
}];

beforeEach(^{
subject = [AROnboardingPersonalizationGeneImageStateReconciler new];
});

it(@"normally returns the onboarding URL", ^{
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"https://d7hftxdivxxvm.cloudfront.net/?resize_to=fill&width=100&height=100&quality=85&src=http://example.com/:version.jpg"]);
});

describe(@"added index path", ^{
beforeEach(^{
[subject addReplacedGene:indexPath];
});

it(@"returns the small URL", ^{
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"http://example.com/thumb.jpg"]);
});

describe(@"after being reset", ^{
beforeEach(^{
[subject reset];
});

it(@"returns the onboarding URL", ^{
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"https://d7hftxdivxxvm.cloudfront.net/?resize_to=fill&width=100&height=100&quality=85&src=http://example.com/:version.jpg"]);
});
});
});

SpecEnd
1 change: 1 addition & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ upcoming:
user_facing:
- Everybody is now required to sign-in - maxim
- New on-boarding - maxim
- Fixed problem with blank gene images during onboarding - ash
- New home view - sarah, maxim, alloy
- Updated Filter View Controller - orta
- Fixes video embedded in articles not playing inline on iOS 10 - alloy
Expand Down

0 comments on commit 052ca51

Please sign in to comment.