From 168b5bb723e9dd136ef33e958640778720a7827d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 16:42:41 +0900 Subject: [PATCH] :v: --- src/web/app/common/mixins.ls | 2 +- src/web/app/common/scripts/i.js | 20 ++++++++++++++++++++ src/web/app/common/scripts/i.ls | 13 ------------- 3 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 src/web/app/common/scripts/i.js delete mode 100644 src/web/app/common/scripts/i.ls diff --git a/src/web/app/common/mixins.ls b/src/web/app/common/mixins.ls index 3999851a9..947fad553 100644 --- a/src/web/app/common/mixins.ls +++ b/src/web/app/common/mixins.ls @@ -3,7 +3,7 @@ riot = require \riot module.exports = (me) ~> i = if me? then me.token else null - (require './scripts/i.ls') me + (require './scripts/i') me riot.mixin \api do api: (require './scripts/api').bind null i diff --git a/src/web/app/common/scripts/i.js b/src/web/app/common/scripts/i.js new file mode 100644 index 000000000..66ce37d50 --- /dev/null +++ b/src/web/app/common/scripts/i.js @@ -0,0 +1,20 @@ +const riot = require('riot'); + +module.exports = me => { + riot.mixin('i', { + init: () => { + this.I = me; + this.SIGNIN = me != null; + + if (this.SIGNIN) { + this.on('mount', () => { + me.on('updated', this.update); + }); + this.on('unmount', () => { + me.off('updated', this.update); + }); + } + }, + me: me + }); +}; diff --git a/src/web/app/common/scripts/i.ls b/src/web/app/common/scripts/i.ls deleted file mode 100644 index 9b5fa8744..000000000 --- a/src/web/app/common/scripts/i.ls +++ /dev/null @@ -1,13 +0,0 @@ -riot = require \riot - -module.exports = (me) -> - riot.mixin \i do - init: -> - @I = me - @SIGNIN = me? - - if @SIGNIN - @on \mount ~> me.on \updated @update - @on \unmount ~> me.off \updated @update - - me: me \ No newline at end of file