diff --git a/package.json b/package.json index 7065e54..76a5448 100644 --- a/package.json +++ b/package.json @@ -40,16 +40,14 @@ "express-session": "^1.15.2", "global": "^4.3.2", "hammerjs": "^2.0.8", - "http-proxy-agent": "^2.1.0", + "http-proxy-agent": "^3.0.0", "ip": "^1.1.5", - "ip-address": "^5.8.9", + "ip-address": "^6.2.0", "isomorphic-fetch": "^2.2.1", "keycode": "^2.1.9", "localforage": "^1.5.0", - "lumber-cli": "^1.3.1", "morgan": "^1.8.2", "multer": "^1.4.1", - "mysql2": "^1.3.6", "node-sass": "^4.11.0", "passport": "^0.4.0", "passport-discord": "^0.1.2", @@ -58,7 +56,6 @@ "passport-json": "^1.2.0", "passport-reddit": "^0.2.4", "passport-vkontakte": "^0.3.2", - "push.js": "1.0.9", "react": "^16.9.0", "react-dom": "^16.9.0", "react-file-download": "^0.3.4", @@ -82,8 +79,7 @@ "three": "^0.112.1", "three-trackballcontrols-ts": "^0.1.2", "url-search-params-polyfill": "^7.0.0", - "visibilityjs": "^1.2.4", - "winston": "^2.3.1", + "winston": "^3.2.1", "ws": "^7.1.2" }, "devDependencies": { @@ -125,13 +121,13 @@ "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.0.1", - "flow-bin": "^0.59.0", + "flow-bin": "^0.115.0", "http-proxy": "^1.16.2", "json-loader": "^0.5.4", "npm-check": "^5.9.0", "react-hot-loader": "^4.12.14", "react-svg-loader": "^3.0.3", - "rimraf": "^2.6.1", + "rimraf": "^3.0.0", "sass-loader": "^8.0.0", "style-loader": "^1.1.2", "webpack": "^4.41.0", diff --git a/src/core/logger.js b/src/core/logger.js index ed2f3ab..7e0a72d 100644 --- a/src/core/logger.js +++ b/src/core/logger.js @@ -10,7 +10,7 @@ import winston from 'winston'; const logger = winston; -export const proxyLogger = new winston.Logger({ +export const proxyLogger = winston.createLogger({ transports: [ new winston.transports.File({ level: 'info', diff --git a/src/store/notifications.js b/src/store/notifications.js index 0ea57ed..c3818a1 100644 --- a/src/store/notifications.js +++ b/src/store/notifications.js @@ -4,47 +4,38 @@ * @flow */ -import Push from 'push.js'; - -function onGranted() { - -} -function onDenied() { - -} - export default (store) => (next) => (action) => { - if (!Push.isSupported) return next(action); + try { + switch (action.type) { + case 'PLACE_PIXEL': { + if (window.Notification + && Notification.permission !== 'granted' + && Notification.permission !== 'denied' + ) { + Notification.requestPermission(); + } + break; + } - switch (action.type) { - case 'PLACE_PIXEL': { - // request permission - // gives callback error now - Push.Permission.request(onGranted, onDenied); + case 'COOLDOWN_END': { + if (window.Notification && Notification.permission === 'granted') { + // eslint-disable-next-line no-unused-vars + const notification = new Notification('Your next pixels are ready', { + icon: '/tile.png', + silent: true, + vibrate: [200, 100], + body: 'You can now place more on pixelplanet.fun :)', + }); + } + break; + } - // clear notifications - Push.clear(); - break; + default: + // nothing } - - case 'COOLDOWN_END': { - Push.create('Your next pixel is now available', { - icon: '/tile.png', - silent: true, - vibrate: [200, 100], - onClick() { - parent.focus(); - window.focus(); - Push.clear(); - }, - }); - break; - } - - default: - // nothing + } catch (e) { + console.error(e); } - return next(action); };