{"action":"created","issue":{"url":"https://api.github.com/repos/darkreader/darkreader/issues/726","repository_url":"https://api.github.com/repos/darkreader/darkreader","labels_url":"https://api.github.com/repos/darkreader/darkreader/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/darkreader/darkreader/issues/726/comments","events_url":"https://api.github.com/repos/darkreader/darkreader/issues/726/events","html_url":"https://github.com/darkreader/darkreader/issues/726","id":359946372,"node_id":"MDU6SXNzdWUzNTk5NDYzNzI=","number":726,"title":"Native dark theme selection algorithm for Discourse forums","user":{"login":"riking","id":627891,"node_id":"MDQ6VXNlcjYyNzg5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/627891?v=4","gravatar_id":"","url":"https://api.github.com/users/riking","html_url":"https://github.com/riking","followers_url":"https://api.github.com/users/riking/followers","following_url":"https://api.github.com/users/riking/following{/other_user}","gists_url":"https://api.github.com/users/riking/gists{/gist_id}","starred_url":"https://api.github.com/users/riking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riking/subscriptions","organizations_url":"https://api.github.com/users/riking/orgs","repos_url":"https://api.github.com/users/riking/repos","events_url":"https://api.github.com/users/riking/events{/privacy}","received_events_url":"https://api.github.com/users/riking/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-13T15:24:41Z","updated_at":"2018-11-01T09:45:31Z","closed_at":null,"author_association":"NONE","body":"Condition: `window.Discourse` is an object\r\n\r\nCode is a function that returns true if native theming was applied.\r\n\r\n```\r\ntry {\r\n  // TODO improve selection herustic\r\n  var theme_object = Discourse.Site.current().get('user_themes').find( th => {\r\n    if(/Dark/.test(th.name)) { return true; }\r\n  } );\r\n  if (!theme_object) { return false; } // No native theme available\r\n  var themeSelector = require('discourse/lib/theme-selector');\r\n  if (themeSelector.currentThemeId() == theme_object.theme_id) {\r\n    return true; // native dark theme already applied\r\n  }\r\n\r\n  // Via meta.discourse.org customizations\r\n            var user = void 0;\r\n            if (user = Discourse.__container__.lookup('current-user:main')) {\r\n                (require('discourse/lib/ajax').ajax)('/u/' + user.username + \".json\").then(function (r) {\r\n                    themeSelector.setLocalTheme([theme_object.theme_id], r.user.user_option.theme_key_seq);\r\n                    window.location.reload();\r\n                });\r\n\r\n                return true;\r\n            } else {\r\n                themeSelector.setLocalTheme([theme_object.theme_id], 0);\r\n                return true;\r\n            }\r\n\r\n} catch (e) {\r\n  return false; // use standard dynamic adjustment\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/darkreader/darkreader/issues/comments/434987743","html_url":"https://github.com/darkreader/darkreader/issues/726#issuecomment-434987743","issue_url":"https://api.github.com/repos/darkreader/darkreader/issues/726","id":434987743,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDk4Nzc0Mw==","user":{"login":"alexanderby","id":9638588,"node_id":"MDQ6VXNlcjk2Mzg1ODg=","avatar_url":"https://avatars2.githubusercontent.com/u/9638588?v=4","gravatar_id":"","url":"https://api.github.com/users/alexanderby","html_url":"https://github.com/alexanderby","followers_url":"https://api.github.com/users/alexanderby/followers","following_url":"https://api.github.com/users/alexanderby/following{/other_user}","gists_url":"https://api.github.com/users/alexanderby/gists{/gist_id}","starred_url":"https://api.github.com/users/alexanderby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexanderby/subscriptions","organizations_url":"https://api.github.com/users/alexanderby/orgs","repos_url":"https://api.github.com/users/alexanderby/repos","events_url":"https://api.github.com/users/alexanderby/events{/privacy}","received_events_url":"https://api.github.com/users/alexanderby/received_events","type":"User","site_admin":false},"created_at":"2018-11-01T09:45:31Z","updated_at":"2018-11-01T09:45:31Z","author_association":"MEMBER","body":"Could you please describe the problem, maybe Dynamic mode already works well there?"}}
{"actor":{"display_login":"alexanderby"}}