{"action":"created","issue":{"url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/30","repository_url":"https://api.github.com/repos/skpm/sketch-module-web-view","labels_url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/30/comments","events_url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/30/events","html_url":"https://github.com/skpm/sketch-module-web-view/pull/30","id":294173353,"number":30,"title":"Reset `wasReady` when closing webview","user":{"login":"cameronmcefee","id":72919,"avatar_url":"https://avatars1.githubusercontent.com/u/72919?v=4","gravatar_id":"","url":"https://api.github.com/users/cameronmcefee","html_url":"https://github.com/cameronmcefee","followers_url":"https://api.github.com/users/cameronmcefee/followers","following_url":"https://api.github.com/users/cameronmcefee/following{/other_user}","gists_url":"https://api.github.com/users/cameronmcefee/gists{/gist_id}","starred_url":"https://api.github.com/users/cameronmcefee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cameronmcefee/subscriptions","organizations_url":"https://api.github.com/users/cameronmcefee/orgs","repos_url":"https://api.github.com/users/cameronmcefee/repos","events_url":"https://api.github.com/users/cameronmcefee/events{/privacy}","received_events_url":"https://api.github.com/users/cameronmcefee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-04T06:04:24Z","updated_at":"2018-02-04T15:24:50Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/skpm/sketch-module-web-view/pulls/30","html_url":"https://github.com/skpm/sketch-module-web-view/pull/30","diff_url":"https://github.com/skpm/sketch-module-web-view/pull/30.diff","patch_url":"https://github.com/skpm/sketch-module-web-view/pull/30.patch"},"body":"Since [FrameLoadDelegateClass is persistent](https://github.com/skpm/sketch-module-web-view/blob/electron-api/lib/webview-api.js#L7), we need to reset the ready state when the window is closed.\r\n\r\nI discovered this when trying to create a panel which, once opened, will toggle visibility on and off on subsequent executions of the \"show this panel\" command. I noticed that if I turned it on, _closed it_, then toggled it one more time, when the window would open, it wouldn't initialize the panel because the ready state was stale from the previous webview.\r\n\r\nThis probably isn't the right solution. I would imagine a better solution would be to reset the _entire_ state rather than just this key, or switch to creating a new class each time rather than persisting it. If you'd rather a particular direction and want me to do the work, let me know what you'd prefer."},"comment":{"url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/comments/362914539","html_url":"https://github.com/skpm/sketch-module-web-view/pull/30#issuecomment-362914539","issue_url":"https://api.github.com/repos/skpm/sketch-module-web-view/issues/30","id":362914539,"user":{"login":"cameronmcefee","id":72919,"avatar_url":"https://avatars1.githubusercontent.com/u/72919?v=4","gravatar_id":"","url":"https://api.github.com/users/cameronmcefee","html_url":"https://github.com/cameronmcefee","followers_url":"https://api.github.com/users/cameronmcefee/followers","following_url":"https://api.github.com/users/cameronmcefee/following{/other_user}","gists_url":"https://api.github.com/users/cameronmcefee/gists{/gist_id}","starred_url":"https://api.github.com/users/cameronmcefee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cameronmcefee/subscriptions","organizations_url":"https://api.github.com/users/cameronmcefee/orgs","repos_url":"https://api.github.com/users/cameronmcefee/repos","events_url":"https://api.github.com/users/cameronmcefee/events{/privacy}","received_events_url":"https://api.github.com/users/cameronmcefee/received_events","type":"User","site_admin":false},"created_at":"2018-02-04T15:24:50Z","updated_at":"2018-02-04T15:24:50Z","author_association":"NONE","body":"I think this may be the cause of it: https://github.com/skpm/sketch-module-web-view/blob/electron-api/lib/webview-api.js#L47. When you create the new class, you're using an old reference to do it (I think)\r\n\r\nHere's a reproducible example. It's a little confusing since I'm just loading google, but imagine your init code happens in `read-to-show`. \r\n\r\n1. Run the command, panel will show, logger will show \"Ready to show\"\r\n2. Run the command again, panel will hide\r\n3. Run the command, panel will show\r\n4. Close the panel\r\n5. Run the command, nothing will happen (but the panel will init without ready action, hence not showing)\r\n6. Run the command again, panel will show but since the ready action wasn't triggered in the previous run, nothing will log. In my case, this is when the panel loads a blank window.\r\n\r\n```\r\nimport BrowserWindow from 'sketch-module-web-view';\r\n\r\nconst id = 'testpanel';\r\n\r\nexport default function(context) {\r\n  const threadDictionary = NSThread.mainThread().threadDictionary();\r\n  let webUI = threadDictionary[id];\r\n\r\n  if (!!webUI) {\r\n    webUI.isVisible() ? webUI.hide() : webUI.show();\r\n    return\r\n  }\r\n\r\n  const options = {\r\n    title: 'Test panel',\r\n    identifier: id,\r\n    width: 260,\r\n    height: 282,\r\n    show: false,\r\n    acceptsFirstMouse: true,\r\n    alwaysOnTop: true\r\n  };\r\n\r\n  webUI = new BrowserWindow(options);\r\n\r\n  webUI.on('ready-to-show', () => {\r\n    console.log('Ready to show')\r\n    webUI.show();\r\n  });\r\n\r\n  webUI.loadURL('https://google.com');\r\n}\r\n```"}}
{"actor":{"display_login":"cameronmcefee"}}