{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/comments/228982605","pull_request_review_id":169372713,"id":228982605,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODk4MjYwNQ==","diff_hunk":"@@ -0,0 +1,58 @@\n+import { EventEmitter } from 'events';\n+import CoreImporter from '../';\n+import { endsWith } from 'lodash';\n+\n+class TextFileImporter extends EventEmitter {\n+  constructor(noteBucket, tagBucket) {\n+    super();\n+    this.noteBucket = noteBucket;\n+    this.tagBucket = tagBucket;\n+  }\n+\n+  importTextFiles = filesArray => {\n+    const coreImporter = new CoreImporter(this.noteBucket, this.tagBucket);\n+    let importedNoteCount = 0;\n+\n+    if (!filesArray) {\n+      this.emit('stats', 'error', 'No text files to import.');\n+      return;\n+    }\n+\n+    const importTextFile = file => {\n+      if (!file || !endsWith(file.name.toLowerCase(), '.txt')) {\n+        return;\n+      }\n+\n+      // Limit file size we will read to 1mb\n+      if (file.size > 1000000) {\n+        return;\n+      }\n+\n+      const fileReader = new FileReader();\n+      fileReader.onload = event => {\n+        const noteContent = event.target.result;\n+        if (!noteContent) {\n+          return;\n+        }\n+\n+        const modifiedTime = file.lastModified / 1000;\n+        coreImporter.importNote({\n+          content: noteContent,\n+          modificationDate: modifiedTime,\n+          creationDate: modifiedTime,\n+        });\n+\n+        importedNoteCount++;\n+        this.emit('status', 'progress', importedNoteCount);\n+      };\n+\n+      fileReader.readAsText(file);\n+    };\n+\n+    for (const file of filesArray) {\n+      importTextFile(file);\n+    }\n+  };","path":"lib/utils/import/text-files/index.js","position":71,"original_position":55,"commit_id":"b51baa9cdb41e6ac7a278321128168b1bcd1e4c5","original_commit_id":"1f013c5dda01232e772ea80133420fce30db072c","user":{"login":"roundhill","id":789137,"node_id":"MDQ6VXNlcjc4OTEzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/789137?v=4","gravatar_id":"","url":"https://api.github.com/users/roundhill","html_url":"https://github.com/roundhill","followers_url":"https://api.github.com/users/roundhill/followers","following_url":"https://api.github.com/users/roundhill/following{/other_user}","gists_url":"https://api.github.com/users/roundhill/gists{/gist_id}","starred_url":"https://api.github.com/users/roundhill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roundhill/subscriptions","organizations_url":"https://api.github.com/users/roundhill/orgs","repos_url":"https://api.github.com/users/roundhill/repos","events_url":"https://api.github.com/users/roundhill/events{/privacy}","received_events_url":"https://api.github.com/users/roundhill/received_events","type":"User","site_admin":false},"body":"Oh nice! I haven't worked with Promises before. 👍 ","created_at":"2018-10-29T15:44:19Z","updated_at":"2018-10-29T15:44:19Z","html_url":"https://github.com/Automattic/simplenote-electron/pull/952#discussion_r228982605","pull_request_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/comments/228982605"},"html":{"href":"https://github.com/Automattic/simplenote-electron/pull/952#discussion_r228982605"},"pull_request":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952"}},"in_reply_to_id":228644763},"pull_request":{"url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952","id":225519174,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1NTE5MTc0","html_url":"https://github.com/Automattic/simplenote-electron/pull/952","diff_url":"https://github.com/Automattic/simplenote-electron/pull/952.diff","patch_url":"https://github.com/Automattic/simplenote-electron/pull/952.patch","issue_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/952","number":952,"state":"open","locked":false,"title":"Add Text File Importer","user":{"login":"roundhill","id":789137,"node_id":"MDQ6VXNlcjc4OTEzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/789137?v=4","gravatar_id":"","url":"https://api.github.com/users/roundhill","html_url":"https://github.com/roundhill","followers_url":"https://api.github.com/users/roundhill/followers","following_url":"https://api.github.com/users/roundhill/following{/other_user}","gists_url":"https://api.github.com/users/roundhill/gists{/gist_id}","starred_url":"https://api.github.com/users/roundhill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roundhill/subscriptions","organizations_url":"https://api.github.com/users/roundhill/orgs","repos_url":"https://api.github.com/users/roundhill/repos","events_url":"https://api.github.com/users/roundhill/events{/privacy}","received_events_url":"https://api.github.com/users/roundhill/received_events","type":"User","site_admin":false},"body":"Building on #922 with an importer for text files in a folder. You simply construct a `TextFileImporter` with the note and tag bucket, and then pass along an array of `File` objects to `importNotes()`:\r\n\r\n```\r\nconst textImporter = new TextFileImporter({\r\n        this.props.noteBucket,\r\n        this.props.tagBucket\r\n      });\r\n\r\n      textImporter.on('status', (eventType, message) => {\r\n        console.log(eventType, message);\r\n      });\r\n\r\n      const filesArray = [array of `File` objects]\r\n      textImporter.importNotes(filesArray);\r\n```\r\n\r\nIt will only pull in files that end in .txt that are less than 1mb in size.\r\n\r\nRefs #916 ","created_at":"2018-10-24T19:16:27Z","updated_at":"2018-10-29T15:44:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ebc90de0a4ed8816f37cb81578bf2c8aebf35571","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/Automattic/simplenote-electron/milestones/10","html_url":"https://github.com/Automattic/simplenote-electron/milestone/10","labels_url":"https://api.github.com/repos/Automattic/simplenote-electron/milestones/10/labels","id":3728175,"node_id":"MDk6TWlsZXN0b25lMzcyODE3NQ==","number":10,"title":"1.2.2","description":"","creator":{"login":"mirka","id":555336,"node_id":"MDQ6VXNlcjU1NTMzNg==","avatar_url":"https://avatars3.githubusercontent.com/u/555336?v=4","gravatar_id":"","url":"https://api.github.com/users/mirka","html_url":"https://github.com/mirka","followers_url":"https://api.github.com/users/mirka/followers","following_url":"https://api.github.com/users/mirka/following{/other_user}","gists_url":"https://api.github.com/users/mirka/gists{/gist_id}","starred_url":"https://api.github.com/users/mirka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirka/subscriptions","organizations_url":"https://api.github.com/users/mirka/orgs","repos_url":"https://api.github.com/users/mirka/repos","events_url":"https://api.github.com/users/mirka/events{/privacy}","received_events_url":"https://api.github.com/users/mirka/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":5,"state":"open","created_at":"2018-10-10T16:45:12Z","updated_at":"2018-10-25T23:11:09Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952/commits","review_comments_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952/comments","review_comment_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/952/comments","statuses_url":"https://api.github.com/repos/Automattic/simplenote-electron/statuses/b51baa9cdb41e6ac7a278321128168b1bcd1e4c5","head":{"label":"Automattic:feature/text-file-parser","ref":"feature/text-file-parser","sha":"b51baa9cdb41e6ac7a278321128168b1bcd1e4c5","user":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":41199577,"node_id":"MDEwOlJlcG9zaXRvcnk0MTE5OTU3Nw==","name":"simplenote-electron","full_name":"Automattic/simplenote-electron","private":false,"owner":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Automattic/simplenote-electron","description":"A Simplenote React app packaged in Electron","fork":false,"url":"https://api.github.com/repos/Automattic/simplenote-electron","forks_url":"https://api.github.com/repos/Automattic/simplenote-electron/forks","keys_url":"https://api.github.com/repos/Automattic/simplenote-electron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/simplenote-electron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/simplenote-electron/teams","hooks_url":"https://api.github.com/repos/Automattic/simplenote-electron/hooks","issue_events_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/simplenote-electron/events","assignees_url":"https://api.github.com/repos/Automattic/simplenote-electron/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/simplenote-electron/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/simplenote-electron/tags","blobs_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/simplenote-electron/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/simplenote-electron/languages","stargazers_url":"https://api.github.com/repos/Automattic/simplenote-electron/stargazers","contributors_url":"https://api.github.com/repos/Automattic/simplenote-electron/contributors","subscribers_url":"https://api.github.com/repos/Automattic/simplenote-electron/subscribers","subscription_url":"https://api.github.com/repos/Automattic/simplenote-electron/subscription","commits_url":"https://api.github.com/repos/Automattic/simplenote-electron/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/simplenote-electron/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/simplenote-electron/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/simplenote-electron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/simplenote-electron/merges","archive_url":"https://api.github.com/repos/Automattic/simplenote-electron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/simplenote-electron/downloads","issues_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/simplenote-electron/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/simplenote-electron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/simplenote-electron/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/simplenote-electron/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/simplenote-electron/deployments","created_at":"2015-08-22T09:06:44Z","updated_at":"2018-10-28T17:02:56Z","pushed_at":"2018-10-29T03:54:58Z","git_url":"git://github.com/Automattic/simplenote-electron.git","ssh_url":"git@github.com:Automattic/simplenote-electron.git","clone_url":"https://github.com/Automattic/simplenote-electron.git","svn_url":"https://github.com/Automattic/simplenote-electron","homepage":"","size":20084,"stargazers_count":1844,"watchers_count":1844,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":261,"mirror_url":null,"archived":false,"open_issues_count":180,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":261,"open_issues":180,"watchers":1844,"default_branch":"master"}},"base":{"label":"Automattic:feature/import-parser","ref":"feature/import-parser","sha":"d31ecbe800d829820b6a3f95347645938ecae2fa","user":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":41199577,"node_id":"MDEwOlJlcG9zaXRvcnk0MTE5OTU3Nw==","name":"simplenote-electron","full_name":"Automattic/simplenote-electron","private":false,"owner":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Automattic/simplenote-electron","description":"A Simplenote React app packaged in Electron","fork":false,"url":"https://api.github.com/repos/Automattic/simplenote-electron","forks_url":"https://api.github.com/repos/Automattic/simplenote-electron/forks","keys_url":"https://api.github.com/repos/Automattic/simplenote-electron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/simplenote-electron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/simplenote-electron/teams","hooks_url":"https://api.github.com/repos/Automattic/simplenote-electron/hooks","issue_events_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/simplenote-electron/events","assignees_url":"https://api.github.com/repos/Automattic/simplenote-electron/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/simplenote-electron/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/simplenote-electron/tags","blobs_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/simplenote-electron/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/simplenote-electron/languages","stargazers_url":"https://api.github.com/repos/Automattic/simplenote-electron/stargazers","contributors_url":"https://api.github.com/repos/Automattic/simplenote-electron/contributors","subscribers_url":"https://api.github.com/repos/Automattic/simplenote-electron/subscribers","subscription_url":"https://api.github.com/repos/Automattic/simplenote-electron/subscription","commits_url":"https://api.github.com/repos/Automattic/simplenote-electron/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/simplenote-electron/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/simplenote-electron/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/simplenote-electron/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/simplenote-electron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/simplenote-electron/merges","archive_url":"https://api.github.com/repos/Automattic/simplenote-electron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/simplenote-electron/downloads","issues_url":"https://api.github.com/repos/Automattic/simplenote-electron/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/simplenote-electron/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/simplenote-electron/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/simplenote-electron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/simplenote-electron/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/simplenote-electron/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/simplenote-electron/deployments","created_at":"2015-08-22T09:06:44Z","updated_at":"2018-10-28T17:02:56Z","pushed_at":"2018-10-29T03:54:58Z","git_url":"git://github.com/Automattic/simplenote-electron.git","ssh_url":"git@github.com:Automattic/simplenote-electron.git","clone_url":"https://github.com/Automattic/simplenote-electron.git","svn_url":"https://github.com/Automattic/simplenote-electron","homepage":"","size":20084,"stargazers_count":1844,"watchers_count":1844,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":261,"mirror_url":null,"archived":false,"open_issues_count":180,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":261,"open_issues":180,"watchers":1844,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952"},"html":{"href":"https://github.com/Automattic/simplenote-electron/pull/952"},"issue":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/issues/952"},"comments":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/issues/952/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/pulls/952/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/simplenote-electron/statuses/b51baa9cdb41e6ac7a278321128168b1bcd1e4c5"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"roundhill"}}