From d158ef287ddef56a4b90583a14008fda42433250 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 13:23:23 +0900 Subject: [PATCH] :v: --- src/web/app/desktop/mixins.ls | 2 +- src/web/app/desktop/scripts/stream.js | 45 +++++++++++++++++++++++++++ src/web/app/desktop/scripts/stream.ls | 38 ---------------------- src/web/app/mobile/mixins.js | 2 +- src/web/app/mobile/scripts/stream.js | 11 +++++++ src/web/app/mobile/scripts/stream.ls | 13 -------- 6 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 src/web/app/desktop/scripts/stream.js delete mode 100644 src/web/app/desktop/scripts/stream.ls create mode 100644 src/web/app/mobile/scripts/stream.js delete mode 100644 src/web/app/mobile/scripts/stream.ls diff --git a/src/web/app/desktop/mixins.ls b/src/web/app/desktop/mixins.ls index b099b4516..054acbe74 100644 --- a/src/web/app/desktop/mixins.ls +++ b/src/web/app/desktop/mixins.ls @@ -2,7 +2,7 @@ riot = require \riot module.exports = (me) ~> if me? - (require './scripts/stream.ls') me + (require './scripts/stream') me require './scripts/user-preview.ls' diff --git a/src/web/app/desktop/scripts/stream.js b/src/web/app/desktop/scripts/stream.js new file mode 100644 index 000000000..ea1548ecf --- /dev/null +++ b/src/web/app/desktop/scripts/stream.js @@ -0,0 +1,45 @@ +const stream = require('../../common/scripts/stream'); +const getPostSummary = require('../../common/scripts/get-post-summary'); +const riot = require('riot'); + +module.exports = me => { + const s = stream(me); + + s.event.on('drive_file_created', file => { + const n = new Notification('ファイルがアップロードされました', { + body: file.name, + icon: file.url + '?thumbnail&size=64' + }); + setTimeout(n.close.bind(n), 5000); + }); + + s.event.on('mention', post => { + const n = new Notification(post.user.name + "さんから:", { + body: getPostSummary(post), + icon: post.user.avatar_url + '?thumbnail&size=64' + }); + setTimeout(n.close.bind(n), 6000); + }); + + s.event.on('reply', post => { + const n = new Notification(post.user.name + "さんから返信:", { + body: getPostSummary(post), + icon: post.user.avatar_url + '?thumbnail&size=64' + }); + setTimeout(n.close.bind(n), 6000); + }); + + s.event.on('quote', post => { + const n = new Notification(post.user.name + "さんが引用:", { + body: getPostSummary(post), + icon: post.user.avatar_url + '?thumbnail&size=64' + }); + setTimeout(n.close.bind(n), 6000); + }); + + riot.mixin('stream', { + stream: s.event, + getStreamState: s.getState, + streamStateEv: s.stateEv + }); +}; diff --git a/src/web/app/desktop/scripts/stream.ls b/src/web/app/desktop/scripts/stream.ls deleted file mode 100644 index 88dac16cb..000000000 --- a/src/web/app/desktop/scripts/stream.ls +++ /dev/null @@ -1,38 +0,0 @@ -# Stream -#================================ - -stream = require '../../common/scripts/stream' -get-post-summary = require '../../common/scripts/get-post-summary' -riot = require \riot - -module.exports = (me) ~> - s = stream me - - s.event.on \drive_file_created (file) ~> - n = new Notification 'ファイルがアップロードされました' do - body: file.name - icon: file.url + '?thumbnail&size=64' - set-timeout (n.close.bind n), 5000ms - - s.event.on \mention (post) ~> - n = new Notification "#{post.user.name}さんから:" do - body: get-post-summary post - icon: post.user.avatar_url + '?thumbnail&size=64' - set-timeout (n.close.bind n), 6000ms - - s.event.on \reply (post) ~> - n = new Notification "#{post.user.name}さんから返信:" do - body: get-post-summary post - icon: post.user.avatar_url + '?thumbnail&size=64' - set-timeout (n.close.bind n), 6000ms - - s.event.on \quote (post) ~> - n = new Notification "#{post.user.name}さんが引用:" do - body: get-post-summary post - icon: post.user.avatar_url + '?thumbnail&size=64' - set-timeout (n.close.bind n), 6000ms - - riot.mixin \stream do - stream: s.event - get-stream-state: s.get-state - stream-state-ev: s.state-ev diff --git a/src/web/app/mobile/mixins.js b/src/web/app/mobile/mixins.js index 6d1626007..cd344d32e 100644 --- a/src/web/app/mobile/mixins.js +++ b/src/web/app/mobile/mixins.js @@ -2,7 +2,7 @@ const riot = require('riot'); module.exports = me => { if (me) { - require('./scripts/stream.ls')(me); + require('./scripts/stream')(me); } require('./scripts/ui.ls'); diff --git a/src/web/app/mobile/scripts/stream.js b/src/web/app/mobile/scripts/stream.js new file mode 100644 index 000000000..e12788f60 --- /dev/null +++ b/src/web/app/mobile/scripts/stream.js @@ -0,0 +1,11 @@ +const stream = require('../../common/scripts/stream'); +const riot = require('riot'); + +module.exports = me => { + const s = stream(me); + riot.mixin('stream', { + stream: s.event, + getStreamState: s.getState, + streamStateEv: s.stateEv + }); +}; diff --git a/src/web/app/mobile/scripts/stream.ls b/src/web/app/mobile/scripts/stream.ls deleted file mode 100644 index 28418d778..000000000 --- a/src/web/app/mobile/scripts/stream.ls +++ /dev/null @@ -1,13 +0,0 @@ -# Stream -#================================ - -stream = require '../../common/scripts/stream' -riot = require \riot - -module.exports = (me) ~> - s = stream me - - riot.mixin \stream do - stream: s.event - get-stream-state: s.get-state - stream-state-ev: s.state-ev