0
0
This commit is contained in:
syuilo 2017-02-18 13:23:23 +09:00
parent 4770e1fab8
commit 2db313986a
6 changed files with 58 additions and 53 deletions

View File

@ -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'

View File

@ -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
});
};

View File

@ -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

View File

@ -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');

View File

@ -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
});
};

View File

@ -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