{"action":"created","issue":{"url":"https://api.github.com/repos/joshwcomeau/guppy/issues/156","repository_url":"https://api.github.com/repos/joshwcomeau/guppy","labels_url":"https://api.github.com/repos/joshwcomeau/guppy/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/joshwcomeau/guppy/issues/156/comments","events_url":"https://api.github.com/repos/joshwcomeau/guppy/issues/156/events","html_url":"https://github.com/joshwcomeau/guppy/issues/156","id":354021085,"node_id":"MDU6SXNzdWUzNTQwMjEwODU=","number":156,"title":"Fixing our persistence layer","user":{"login":"joshwcomeau","id":6692932,"node_id":"MDQ6VXNlcjY2OTI5MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/6692932?v=4","gravatar_id":"","url":"https://api.github.com/users/joshwcomeau","html_url":"https://github.com/joshwcomeau","followers_url":"https://api.github.com/users/joshwcomeau/followers","following_url":"https://api.github.com/users/joshwcomeau/following{/other_user}","gists_url":"https://api.github.com/users/joshwcomeau/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwcomeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwcomeau/subscriptions","organizations_url":"https://api.github.com/users/joshwcomeau/orgs","repos_url":"https://api.github.com/users/joshwcomeau/repos","events_url":"https://api.github.com/users/joshwcomeau/events{/privacy}","received_events_url":"https://api.github.com/users/joshwcomeau/received_events","type":"User","site_admin":false},"labels":[{"id":939204840,"node_id":"MDU6TGFiZWw5MzkyMDQ4NDA=","url":"https://api.github.com/repos/joshwcomeau/guppy/labels/bug","name":"bug","color":"d73a4a","default":true},{"id":939204841,"node_id":"MDU6TGFiZWw5MzkyMDQ4NDE=","url":"https://api.github.com/repos/joshwcomeau/guppy/labels/top%20priority","name":"top priority","color":"ff9000","default":false}],"state":"open","locked":false,"assignee":{"login":"joshwcomeau","id":6692932,"node_id":"MDQ6VXNlcjY2OTI5MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/6692932?v=4","gravatar_id":"","url":"https://api.github.com/users/joshwcomeau","html_url":"https://github.com/joshwcomeau","followers_url":"https://api.github.com/users/joshwcomeau/followers","following_url":"https://api.github.com/users/joshwcomeau/following{/other_user}","gists_url":"https://api.github.com/users/joshwcomeau/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwcomeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwcomeau/subscriptions","organizations_url":"https://api.github.com/users/joshwcomeau/orgs","repos_url":"https://api.github.com/users/joshwcomeau/repos","events_url":"https://api.github.com/users/joshwcomeau/events{/privacy}","received_events_url":"https://api.github.com/users/joshwcomeau/received_events","type":"User","site_admin":false},"assignees":[{"login":"joshwcomeau","id":6692932,"node_id":"MDQ6VXNlcjY2OTI5MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/6692932?v=4","gravatar_id":"","url":"https://api.github.com/users/joshwcomeau","html_url":"https://github.com/joshwcomeau","followers_url":"https://api.github.com/users/joshwcomeau/followers","following_url":"https://api.github.com/users/joshwcomeau/following{/other_user}","gists_url":"https://api.github.com/users/joshwcomeau/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwcomeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwcomeau/subscriptions","organizations_url":"https://api.github.com/users/joshwcomeau/orgs","repos_url":"https://api.github.com/users/joshwcomeau/repos","events_url":"https://api.github.com/users/joshwcomeau/events{/privacy}","received_events_url":"https://api.github.com/users/joshwcomeau/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-08-25T15:28:28Z","updated_at":"2018-08-25T15:30:23Z","closed_at":null,"author_association":"OWNER","body":"During app runtime, state is stored primarily in Redux. What list of projects are, where the logs are recorded, which project is selected, etc.\r\n\r\nIn our current implementation, we're also duplicating all of that redux state in \"electron-store\" (similar to `localStorage` on the web). That way, when the app boots up, we restore the same session from the last time it was used.\r\n\r\nThis works great, except when we actually want to change the reducer structure. This happened in #70 when @Kermit-Xuan (following my advice) updated `paths.reducer` to have a new top-level structure. In that case, the persisted Redux state is fed into the new reducer, and the whole thing blows up.\r\n\r\nThe Redux persistence layer might be a premature optimization; it doesn't actually take that long to parse the disk and reconstruct the state! However, there are two crucial things it does right now:\r\n\r\n- It keeps track of which projects are in Guppy!\r\n- It keeps track of which project is selected\r\n\r\nI want to kill the redux persistence, since it makes things a lot more complicated and makes it harder for us to change things. But, we need to find an alternate solution for those two concerns.\r\n\r\nMy current thinking is that we can use `electron-store` to store raw data about the paths to projects, as well as which project is currently selected. If we're storing raw data, then we'd only have to update how that raw data is parsed when our reducer structure changes.\r\n\r\nI imagine storing this kind of structure:\r\n\r\n```js\r\n{\r\n  projectPaths: {\r\n    'guppy-project': '~/guppy-projects-dev/guppy-project',\r\n    'something-imported': '~/work/some-project',\r\n  },\r\n  selectedProjectId: 'guppy-project',\r\n}\r\n``` \r\n\r\nThen, we'd need to do the following on mount:\r\n\r\n- Parse all the paths provided to get the full project info\r\n- Dispatch an action that sets the projects, and sets the selected project ID as well.\r\n\r\nThis feels dramatically more resilient than what we're doing now, and comes with a few other side-benefits:\r\n- Right now we're assuming any folder in `~/guppy-projects-dev` is a Guppy project, and we can't select another project to build from. This change will set the foundation for #70 and make it a bit simpler\r\n- It's simpler! Right now we have this weird thing where we're storing _almost_ the exact redux state, but we make some changes to it to avoid persisting things we don't want persisted.\r\n\r\nI'm gonna start work on this today"},"comment":{"url":"https://api.github.com/repos/joshwcomeau/guppy/issues/comments/415977062","html_url":"https://github.com/joshwcomeau/guppy/issues/156#issuecomment-415977062","issue_url":"https://api.github.com/repos/joshwcomeau/guppy/issues/156","id":415977062,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTk3NzA2Mg==","user":{"login":"mathieudutour","id":3254314,"node_id":"MDQ6VXNlcjMyNTQzMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3254314?v=4","gravatar_id":"","url":"https://api.github.com/users/mathieudutour","html_url":"https://github.com/mathieudutour","followers_url":"https://api.github.com/users/mathieudutour/followers","following_url":"https://api.github.com/users/mathieudutour/following{/other_user}","gists_url":"https://api.github.com/users/mathieudutour/gists{/gist_id}","starred_url":"https://api.github.com/users/mathieudutour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathieudutour/subscriptions","organizations_url":"https://api.github.com/users/mathieudutour/orgs","repos_url":"https://api.github.com/users/mathieudutour/repos","events_url":"https://api.github.com/users/mathieudutour/events{/privacy}","received_events_url":"https://api.github.com/users/mathieudutour/received_events","type":"User","site_admin":false},"created_at":"2018-08-25T15:30:23Z","updated_at":"2018-08-25T15:30:23Z","author_association":"COLLABORATOR","body":"I worked a bunch on this issue before. You can have a look at https://github.com/react-stack/redux-storage. There is already a engine written for `electron-store` (https://github.com/collmot/redux-storage-engine-electron-store). \r\n\r\nThen you can have a bunch of middlewares to handle:\r\n- migrations (https://github.com/mathieudutour/redux-storage-decorator-migrate) (disclamer, I wrote it)\r\n- debouncing so that you don't write to disk every 10 ms\r\n- filtering which actions you want to trigger the save\r\n- etc"}}
{"actor":{"display_login":"mathieudutour"}}