Skip to content

Conversation

@djih
Copy link
Member

@djih djih commented Aug 10, 2016

… guarded db interactions with apikey check

This is part 1 of the database migration work. We need to migrate any database interaction logic in the init method into the initializeApiKey method since we will need the apiKey to interact with the database. I also run the init logic on the backgroundQueue, removing the need for a separate initializerQueue.

Few things to note:

  • _dbHelper is initialized in initializeApiKey now. Any public methods that interact with the database such as setUserId, setDeviceId, identify, etc need to be guarded with an apiKey check to ensure [self.dbHelper] is available
  • I moved [self addObservers] to initializeApiKey since enterBackground interacts with the DB by saving the current timestamp.
  • Most tests still pass. Just need to flush the background queue instead of the initializerQueue.
  • Reran all tests on iPhone 4, iPhone 5, iPhone 6S Plus, tested demo app on test device

_backgroundQueue.name = BACKGROUND_QUEUE_NAME;

[_initializerQueue addOperationWithBlock:^{
[_backgroundQueue addOperationWithBlock:^{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to make sure here that this is guaranteed to be called before any other _backgroundQueue addOperationWithBlock calls can be made

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just searched through the code and all addOperationWithBlock and runOnBackgroundQueue calls are protected with an apiKey check, so they need to call initializeApiKey before any of those methods work.

@djih djih mentioned this pull request Aug 12, 2016
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.

3 participants