{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/comments/86990939","pull_request_review_id":7620241,"id":86990939,"diff_hunk":"@@ -0,0 +1,88 @@\n+//\n+//  PreferencesDB.swift\n+//  magnet\n+//\n+//  Created by sam on 11/7/16.\n+//  Copyright © 2016 Mozilla. All rights reserved.\n+//\n+\n+import Foundation\n+import SQLite\n+\n+class PreferencesDB {\n+  private static var singleton: PreferencesDB!\n+  private let table: Table = Table(\"preferences\")\n+  private let columnPrefKey = Expression<String>(\"pref_key\");\n+  private let columnPrefValue = Expression<String>(\"value\");\n+  private var db: Connection\n+  \n+  static func get() -> PreferencesDB {\n+    let lockQueue = dispatch_queue_create(\"com.mozilla.magnet.preferences\", nil);\n+    \n+    dispatch_sync(lockQueue) {\n+      if (singleton == nil) {\n+        singleton = PreferencesDB()\n+      }\n+    }\n+    \n+    return singleton\n+  }\n+  \n+  private init() {\n+    let path = NSSearchPathForDirectoriesInDomains(\n+      .DocumentDirectory,\n+      .UserDomainMask,\n+      true).first!\n+    \n+    db = try! Connection(\"\\(path)/history.sqlite3\")","path":"ios/PreferencesDB.swift","position":37,"original_position":37,"commit_id":"f9566d0a2fee656a44d979c6f86038646ae52d10","original_commit_id":"f9566d0a2fee656a44d979c6f86038646ae52d10","user":{"login":"samgiles","id":840334,"avatar_url":"https://avatars.githubusercontent.com/u/840334?v=3","gravatar_id":"","url":"https://api.github.com/users/samgiles","html_url":"https://github.com/samgiles","followers_url":"https://api.github.com/users/samgiles/followers","following_url":"https://api.github.com/users/samgiles/following{/other_user}","gists_url":"https://api.github.com/users/samgiles/gists{/gist_id}","starred_url":"https://api.github.com/users/samgiles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samgiles/subscriptions","organizations_url":"https://api.github.com/users/samgiles/orgs","repos_url":"https://api.github.com/users/samgiles/repos","events_url":"https://api.github.com/users/samgiles/events{/privacy}","received_events_url":"https://api.github.com/users/samgiles/received_events","type":"User","site_admin":false},"body":"I noticed this is what the subscriptions was doing and thought you were heading for one DB?","created_at":"2016-11-08T13:50:08Z","updated_at":"2016-11-08T13:50:09Z","html_url":"https://github.com/mozilla-magnet/magnet-client/pull/319#discussion_r86990939","pull_request_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319","_links":{"self":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/comments/86990939"},"html":{"href":"https://github.com/mozilla-magnet/magnet-client/pull/319#discussion_r86990939"},"pull_request":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319","id":92772305,"html_url":"https://github.com/mozilla-magnet/magnet-client/pull/319","diff_url":"https://github.com/mozilla-magnet/magnet-client/pull/319.diff","patch_url":"https://github.com/mozilla-magnet/magnet-client/pull/319.patch","issue_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/319","number":319,"state":"open","locked":false,"title":"Part 1 of #296: Expose preferences to the native side","user":{"login":"samgiles","id":840334,"avatar_url":"https://avatars.githubusercontent.com/u/840334?v=3","gravatar_id":"","url":"https://api.github.com/users/samgiles","html_url":"https://github.com/samgiles","followers_url":"https://api.github.com/users/samgiles/followers","following_url":"https://api.github.com/users/samgiles/following{/other_user}","gists_url":"https://api.github.com/users/samgiles/gists{/gist_id}","starred_url":"https://api.github.com/users/samgiles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samgiles/subscriptions","organizations_url":"https://api.github.com/users/samgiles/orgs","repos_url":"https://api.github.com/users/samgiles/repos","events_url":"https://api.github.com/users/samgiles/events{/privacy}","received_events_url":"https://api.github.com/users/samgiles/received_events","type":"User","site_admin":false},"body":"Part 1 for #296.\r\n\r\nRemoves the dependency on AsyncStorage \\o/.\r\n\r\nI've also tried to make the backend API for Preferences more generic than booleans only.\r\n\r\nr? @wilsonpage Android: Also see how there's a mutex lock over the delete and update methods, should prevent weird races.  We might want to apply that technique in the subscriptions API too. \r\n\r\nr? @arcturus iOS  I'm not sure about potential concurrency issues here, do we need a mutex marshalling access through the API for remove and update?\r\n\r\n","created_at":"2016-11-08T12:54:12Z","updated_at":"2016-11-08T13:50:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8df04205277a55fe7999d1eb8fe83c014036f806","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319/commits","review_comments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319/comments","review_comment_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/319/comments","statuses_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/statuses/f9566d0a2fee656a44d979c6f86038646ae52d10","head":{"label":"mozilla-magnet:296-1-expose-prefs","ref":"296-1-expose-prefs","sha":"f9566d0a2fee656a44d979c6f86038646ae52d10","user":{"login":"mozilla-magnet","id":17905978,"avatar_url":"https://avatars.githubusercontent.com/u/17905978?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-magnet","html_url":"https://github.com/mozilla-magnet","followers_url":"https://api.github.com/users/mozilla-magnet/followers","following_url":"https://api.github.com/users/mozilla-magnet/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-magnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-magnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-magnet/subscriptions","organizations_url":"https://api.github.com/users/mozilla-magnet/orgs","repos_url":"https://api.github.com/users/mozilla-magnet/repos","events_url":"https://api.github.com/users/mozilla-magnet/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-magnet/received_events","type":"Organization","site_admin":false},"repo":{"id":50177593,"name":"magnet-client","full_name":"mozilla-magnet/magnet-client","owner":{"login":"mozilla-magnet","id":17905978,"avatar_url":"https://avatars.githubusercontent.com/u/17905978?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-magnet","html_url":"https://github.com/mozilla-magnet","followers_url":"https://api.github.com/users/mozilla-magnet/followers","following_url":"https://api.github.com/users/mozilla-magnet/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-magnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-magnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-magnet/subscriptions","organizations_url":"https://api.github.com/users/mozilla-magnet/orgs","repos_url":"https://api.github.com/users/mozilla-magnet/repos","events_url":"https://api.github.com/users/mozilla-magnet/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-magnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-magnet/magnet-client","description":"A nearby content discovery client for Android & iOS","fork":false,"url":"https://api.github.com/repos/mozilla-magnet/magnet-client","forks_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/forks","keys_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/teams","hooks_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/hooks","issue_events_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/events","assignees_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/tags","blobs_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/languages","stargazers_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/stargazers","contributors_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/contributors","subscribers_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/subscribers","subscription_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/subscription","commits_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/merges","archive_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/downloads","issues_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/deployments","created_at":"2016-01-22T11:32:12Z","updated_at":"2016-10-31T17:57:52Z","pushed_at":"2016-11-08T13:21:06Z","git_url":"git://github.com/mozilla-magnet/magnet-client.git","ssh_url":"git@github.com:mozilla-magnet/magnet-client.git","clone_url":"https://github.com/mozilla-magnet/magnet-client.git","svn_url":"https://github.com/mozilla-magnet/magnet-client","homepage":"","size":52979,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":84,"forks":9,"open_issues":84,"watchers":8,"default_branch":"master"}},"base":{"label":"mozilla-magnet:master","ref":"master","sha":"e8bd1de0aa71219e7fe9d71a352c971457eec616","user":{"login":"mozilla-magnet","id":17905978,"avatar_url":"https://avatars.githubusercontent.com/u/17905978?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-magnet","html_url":"https://github.com/mozilla-magnet","followers_url":"https://api.github.com/users/mozilla-magnet/followers","following_url":"https://api.github.com/users/mozilla-magnet/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-magnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-magnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-magnet/subscriptions","organizations_url":"https://api.github.com/users/mozilla-magnet/orgs","repos_url":"https://api.github.com/users/mozilla-magnet/repos","events_url":"https://api.github.com/users/mozilla-magnet/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-magnet/received_events","type":"Organization","site_admin":false},"repo":{"id":50177593,"name":"magnet-client","full_name":"mozilla-magnet/magnet-client","owner":{"login":"mozilla-magnet","id":17905978,"avatar_url":"https://avatars.githubusercontent.com/u/17905978?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-magnet","html_url":"https://github.com/mozilla-magnet","followers_url":"https://api.github.com/users/mozilla-magnet/followers","following_url":"https://api.github.com/users/mozilla-magnet/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-magnet/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-magnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-magnet/subscriptions","organizations_url":"https://api.github.com/users/mozilla-magnet/orgs","repos_url":"https://api.github.com/users/mozilla-magnet/repos","events_url":"https://api.github.com/users/mozilla-magnet/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-magnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-magnet/magnet-client","description":"A nearby content discovery client for Android & iOS","fork":false,"url":"https://api.github.com/repos/mozilla-magnet/magnet-client","forks_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/forks","keys_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/teams","hooks_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/hooks","issue_events_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/events","assignees_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/tags","blobs_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/languages","stargazers_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/stargazers","contributors_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/contributors","subscribers_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/subscribers","subscription_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/subscription","commits_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/merges","archive_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/downloads","issues_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-magnet/magnet-client/deployments","created_at":"2016-01-22T11:32:12Z","updated_at":"2016-10-31T17:57:52Z","pushed_at":"2016-11-08T13:21:06Z","git_url":"git://github.com/mozilla-magnet/magnet-client.git","ssh_url":"git@github.com:mozilla-magnet/magnet-client.git","clone_url":"https://github.com/mozilla-magnet/magnet-client.git","svn_url":"https://github.com/mozilla-magnet/magnet-client","homepage":"","size":52979,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":84,"forks":9,"open_issues":84,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319"},"html":{"href":"https://github.com/mozilla-magnet/magnet-client/pull/319"},"issue":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/319"},"comments":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/issues/319/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/pulls/319/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-magnet/magnet-client/statuses/f9566d0a2fee656a44d979c6f86038646ae52d10"}}}}
{"actor":{"display_login":"samgiles"}}