@@ -131,247 +131,263 @@
this.mixin('api');
this.mixin('stream');
- this.files = []
- this.folders = []
- this.hierarchyFolders = []
- this.selected-files = []
+ this.files = [];
+ this.folders = [];
+ this.hierarchyFolders = [];
+ this.selectedFiles = [];
// 現在の階層(フォルダ)
// * null でルートを表す
- this.folder = null
+ this.folder = null;
- this.file = null
+ this.file = null;
- this.is-select-mode = this.opts.select? and this.opts.select
- this.multiple = if this.opts.multiple? then this.opts.multiple else false
+ this.isSelectMode = this.opts.select;
+ this.multiple =this.opts.multiple;
this.on('mount', () => {
- this.stream.on 'drive_file_created' this.onStreamDriveFileCreated
- this.stream.on 'drive_file_updated' this.onStreamDriveFileUpdated
- this.stream.on 'drive_folder_created' this.onStreamDriveFolderCreated
- this.stream.on 'drive_folder_updated' this.onStreamDriveFolderUpdated
+ this.stream.on('drive_file_created', this.onStreamDriveFileCreated);
+ this.stream.on('drive_file_updated', this.onStreamDriveFileUpdated);
+ this.stream.on('drive_folder_created', this.onStreamDriveFolderCreated);
+ this.stream.on('drive_folder_updated', this.onStreamDriveFolderUpdated);
// Riotのバグでnullを渡しても""になる
// https://github.com/riot/riot/issues/2080
- #if this.opts.folder?
- if this.opts.folder? and this.opts.folder != ''
- @cd this.opts.folder, true
- else if this.opts.file? and this.opts.file != ''
- @cf this.opts.file, true
- else
+ //if (this.opts.folder)
+ //if (this.opts.file)
+ if (this.opts.folder && this.opts.folder != '') {
+ this.cd(this.opts.folder, true);
+ } else if (this.opts.file && this.opts.file != '') {
+ this.cf(this.opts.file, true);
+ } else {
this.load();
+ }
+ });
this.on('unmount', () => {
- this.stream.off 'drive_file_created' this.onStreamDriveFileCreated
- this.stream.off 'drive_file_updated' this.onStreamDriveFileUpdated
- this.stream.off 'drive_folder_created' this.onStreamDriveFolderCreated
- this.stream.off 'drive_folder_updated' this.onStreamDriveFolderUpdated
+ this.stream.off('drive_file_created', this.onStreamDriveFileCreated);
+ this.stream.off('drive_file_updated', this.onStreamDriveFileUpdated);
+ this.stream.off('drive_folder_created', this.onStreamDriveFolderCreated);
+ this.stream.off('drive_folder_updated', this.onStreamDriveFolderUpdated);
+ });
- this.onStreamDriveFileCreated = (file) => {
- this.addFile file, true
+ this.onStreamDriveFileCreated = file => {
+ this.addFile(file, true);
+ };
- this.onStreamDriveFileUpdated = (file) => {
- current = if this.folder? then this.folder.id else null
- if current != file.folder_id
- @remove-file file
- else
- this.addFile file, true
+ this.onStreamDriveFileUpdated = file => {
+ const current = this.folder ? this.folder.id : null;
+ if (current != file.folder_id) {
+ this.removeFile(file);
+ } else {
+ this.addFile(file, true);
+ }
+ };
- this.onStreamDriveFolderCreated = (folder) => {
- this.addFolder folder, true
+ this.onStreamDriveFolderCreated = folder => {
+ this.addFolder(folder, true);
+ };
- this.onStreamDriveFolderUpdated = (folder) => {
- current = if this.folder? then this.folder.id else null
- if current != folder.parent_id
- this.removeFolder folder
- else
- this.addFolder folder, true
+ this.onStreamDriveFolderUpdated = folder => {
+ const current = this.folder ? this.folder.id : null;
+ if (current != folder.parent_id) {
+ this.removeFolder(folder);
+ } else {
+ this.addFolder(folder, true);
+ }
+ };
- @_move = (ev) =>
- this.move ev.item.folder
+ this.move = ev => {
+ this.move(ev.item.folder);
+ };
- this.move = (target-folder) => {
- @cd target-folder
+ this.cd = (target, silent = false) => {
+ this.file = null;
- this.cd = (target-folder, silent = false) => {
- this.file = null
+ if (target == null) {
+ this.goRoot();
+ return;
+ } else if (typeof target == 'object') target = target.id;
- if target-folder? and typeof target-folder == 'object'
- target-folder = target-folder.id
-
- if target-folder == null
- @go-root!
- return
-
- this.loading = true
- this.update();
+ this.update({
+ fetching: true
+ });
this.api('drive/folders/show', {
- folder_id: target-folder
- }).then((folder) => {
- this.folder = folder
- this.hierarchyFolders = []
+ folder_id: target
+ }).then(folder => {
+ this.folder = folder;
+ this.hierarchyFolders = [];
- x = (f) =>
- @hierarchyFolders.unshift f
- if f.parent?
- x f.parent
-
- if folder.parent?
- x folder.parent
+ if (folder.parent) dive(folder.parent);
this.update();
- this.trigger 'open-folder' this.folder, silent
+ this.trigger('open-folder', this.folder, silent);
this.load();
- .catch (err, text-status) ->
- console.error err
+ });
+ };
- this.add-folder = (folder, unshift = false) => {
- current = if this.folder? then this.folder.id else null
- if current != folder.parent_id
- return
+ this.addFolder = (folder, unshift = false) => {
+ const current = this.folder ? this.folder.id : null;
+ // 追加しようとしているフォルダが、今居る階層とは違う階層のものだったら中断
+ if (current != folder.parent_id) return;
- if (this.folders.some (f) => f.id == folder.id)
- return
+ // 追加しようとしているフォルダを既に所有してたら中断
+ if (this.folders.some(f => f.id == folder.id)) return;
- if unshift
- this.folders.unshift folder
- else
- this.folders.push folder
+ if (unshift) {
+ this.folders.unshift(folder);
+ } else {
+ this.folders.push(folder);
+ }
this.update();
+ };
- this.add-file = (file, unshift = false) => {
- current = if this.folder? then this.folder.id else null
- if current != file.folder_id
- return
+ this.addFile = (file, unshift = false) => {
+ const current = this.folder ? this.folder.id : null;
+ // 追加しようとしているファイルが、今居る階層とは違う階層のものだったら中断
+ if (current != file.folder_id) return;
- if (this.files.some (f) => f.id == file.id)
- exist = (this.files.map (f) -> f.id).index-of file.id
- this.files[exist] = file
+ if (this.files.some(f => f.id == file.id)) {
+ const exist = this.files.map(f => f.id).indexOf(file.id);
+ this.files[exist] = file;
this.update();
- return
+ return;
+ }
- if unshift
- this.files.unshift file
- else
- this.files.push file
+ if (unshift) {
+ this.files.unshift(file);
+ } else {
+ this.files.push(file);
+ }
this.update();
+ };
- this.remove-folder = (folder) => {
- if typeof folder == 'object'
- folder = folder.id
- this.folders = this.folders.filter (f) -> f.id != folder
+ this.removeFolder = folder => {
+ if (typeof folder == 'object') folder = folder.id;
+ this.folders = this.folders.filter(f => f.id != folder);
this.update();
+ };
- this.remove-file = (file) => {
- if typeof file == 'object'
- file = file.id
- this.files = this.files.filter (f) -> f.id != file
+ this.removeFile = file => {
+ if (typeof file == 'object') file = file.id;
+ this.files = this.files.filter(f => f.id != file);
this.update();
+ };
- this.go-root = () => {
- if this.folder != null or this.file != null
- this.file = null
- this.folder = null
- this.hierarchyFolders = []
- this.update();
+ this.goRoot = () => {
+ if (this.folder || this.file) {
+ this.update({
+ file: null,
+ folder: null,
+ hierarchyFolders: []
+ });
this.trigger('move-root');
this.load();
+ }
+ };
this.load = () => {
- this.folders = []
- this.files = []
- this.more-folders = false
- this.more-files = false
- this.loading = true
- this.update();
+ this.update({
+ folders: [],
+ files: [],
+ moreFolders: false,
+ moreFiles: false,
+ fetching: true
+ });
this.trigger('begin-load');
- load-folders = null
- load-files = null
+ let fetchedFolders = null;
+ let fetchedFiles = null;
- folders-max = 20
- files-max = 20
+ const foldersMax = 20;
+ const filesMax = 20;
// フォルダ一覧取得
this.api('drive/folders', {
- folder_id: if this.folder? then this.folder.id else null
- limit: folders-max + 1
- }).then((folders) => {
- if folders.length == folders-max + 1
- this.more-folders = true
- folders.pop!
- load-folders := folders
- complete!
- .catch (err, text-status) =>
- console.error err
+ folder_id: this.folder ? this.folder.id : null,
+ limit: foldersMax + 1
+ }).then(folders => {
+ if (folders.length == foldersMax + 1) {
+ this.moreFolders = true;
+ folders.pop();
+ }
+ fetchedFolders = folders;
+ complete();
+ });
// ファイル一覧取得
this.api('drive/files', {
- folder_id: if this.folder? then this.folder.id else null
- limit: files-max + 1
- }).then((files) => {
- if files.length == files-max + 1
- this.more-files = true
- files.pop!
- load-files := files
- complete!
- .catch (err, text-status) =>
- console.error err
-
- flag = false
- complete = =>
- if flag
- load-folders.forEach (folder) =>
- this.addFolder folder
- load-files.forEach (file) =>
- this.addFile file
- this.loading = false
- this.update();
+ folder_id: this.folder ? this.folder.id : null,
+ limit: filesMax + 1
+ }).then(files => {
+ if (files.length == filesMax + 1) {
+ this.moreFiles = true;
+ files.pop();
+ }
+ fetchedFiles = files;
+ complete();
+ });
+ let flag = false;
+ complete = () => {
+ if (flag) {
+ fetchedFolders.forEach(folder => this.addFolder);
+ fetchedFiles.forEach(file => this.addFile);
+ this.update({
+ fetching: false
+ });
+ // 一連の読み込みが完了したイベントを発行
this.trigger('loaded');
- else
- flag := true
+ } else {
+ flag = true;
+ // 一連の読み込みが半分完了したイベントを発行
this.trigger('load-mid');
+ }
+ };
+ };
- this.choose-file = (file) => {
- if @is-select-mode
- exist = @selected-files.some (f) => f.id == file.id
- if exist
- this.selected-files = (@selected-files.filter (f) => { f.id != file.id)
- else
- @selected-files.push file
+ this.chooseFile = file => {
+ if (this.isSelectMode) {
+ if (this.selectedFiles.some(f => f.id == file.id)) {
+ this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id);
+ } else {
+ this.selectedFiles.push(file);
+ }
this.update();
- this.trigger 'change-selected' @selected-files
- else
- @cf file
+ this.trigger('change-selected', this.selectedFiles);
+ } else {
+ this.cf(file);
+ }
+ };
this.cf = (file, silent = false) => {
- if typeof file == 'object'
- file = file.id
+ if (typeof file == 'object') file = file.id;
- this.loading = true
- this.update();
+ this.update({
+ fetching: true
+ });
this.api('drive/files/show', {
file_id: file
- }).then((file) => {
- this.file = file
- this.folder = null
- this.hierarchyFolders = []
+ }).then(file => {
+ this.file = file;
+ this.folder = null;
+ this.hierarchyFolders = [];
- x = (f) =>
- @hierarchyFolders.unshift f
- if f.parent?
- x f.parent
-
- if file.folder?
- x file.folder
+ if (file.folder) dive(file.folder);
this.update();
- this.trigger 'open-file' this.file, silent
+ this.trigger('open-file', this.file, silent);
+ });
+ };
+
+ const dive = folder => {
+ this.hierarchyFolders.unshift(folder);
+ if (folder.parent) dive(folder.parent);
+ };
diff --git a/src/web/app/mobile/tags/drive/file-viewer.tag b/src/web/app/mobile/tags/drive/file-viewer.tag
index e91a451c0d..78a10b83b4 100644
--- a/src/web/app/mobile/tags/drive/file-viewer.tag
+++ b/src/web/app/mobile/tags/drive/file-viewer.tag
@@ -185,17 +185,18 @@
this.mixin('api');
- this.file = this.opts.file
- this.kind = this.file.type.split '/' .0
+ this.file = this.opts.file;
+ this.kind = this.file.type.split('/')[0];
this.rename = () => {
- name = window.prompt '名前を変更' this.file.name
- if name? and name != '' and name != this.file.name
- this.api('drive/files/update', {
- file_id: this.file.id,
- name: name
- }).then(() => {
- this.parent.cf this.file, true
-
+ const name = window.prompt('名前を変更', this.file.name);
+ if (name == null || name == '' || name == this.file.name) return;
+ this.api('drive/files/update', {
+ file_id: this.file.id,
+ name: name
+ }).then(() => {
+ this.parent.cf(this.file, true);
+ });
+ };
diff --git a/src/web/app/mobile/tags/drive/file.tag b/src/web/app/mobile/tags/drive/file.tag
index 77b5b220ad..f800fd69e0 100644
--- a/src/web/app/mobile/tags/drive/file.tag
+++ b/src/web/app/mobile/tags/drive/file.tag
@@ -124,14 +124,16 @@
diff --git a/src/web/app/mobile/tags/drive/folder.tag b/src/web/app/mobile/tags/drive/folder.tag
index 4c4727a308..093e742929 100644
--- a/src/web/app/mobile/tags/drive/folder.tag
+++ b/src/web/app/mobile/tags/drive/folder.tag
@@ -37,10 +37,11 @@
diff --git a/src/web/app/mobile/tags/follow-button.tag b/src/web/app/mobile/tags/follow-button.tag
index 43fcc3499c..ae6d19f593 100644
--- a/src/web/app/mobile/tags/follow-button.tag
+++ b/src/web/app/mobile/tags/follow-button.tag
@@ -52,54 +52,70 @@
this.mixin('is-promise');
this.mixin('stream');
- this.user = null
- this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user
- this.init = true
- this.wait = false
+ this.user = null;
+ this.userPromise = this.isPromise(this.opts.user)
+ ? this.opts.user
+ : Promise.resolve(this.opts.user);
+ this.init = true;
+ this.wait = false;
this.on('mount', () => {
- this.user-promise}).then((user) => {
- this.user = user
- this.init = false
- this.update();
- this.stream.on 'follow' this.on-stream-follow
- this.stream.on 'unfollow' this.on-stream-unfollow
+ this.userPromise.then(user => {
+ this.update({
+ init: false,
+ user: user
+ });
+ this.stream.on('follow', this.onStreamFollow);
+ this.stream.on('unfollow', this.onStreamUnfollow);
+ });
+ });
this.on('unmount', () => {
- this.stream.off 'follow' this.on-stream-follow
- this.stream.off 'unfollow' this.on-stream-unfollow
+ this.stream.off('follow', this.onStreamFollow);
+ this.stream.off('unfollow', this.onStreamUnfollow);
+ });
- this.on-stream-follow = (user) => {
- if user.id == this.user.id
- this.user = user
- this.update();
+ this.onStreamFollow = user => {
+ if (user.id == this.user.id) {
+ this.update({
+ user: user
+ });
+ }
+ };
- this.on-stream-unfollow = (user) => {
- if user.id == this.user.id
- this.user = user
- this.update();
+ this.onStreamUnfollow = user => {
+ if (user.id == this.user.id) {
+ this.update({
+ user: user
+ });
+ }
+ };
this.onclick = () => {
- this.wait = true
- if this.user.is_following
+ this.wait = true;
+ if (this.user.is_following) {
this.api('following/delete', {
user_id: this.user.id
}).then(() => {
- this.user.is_following = false
- .catch (err) ->
- console.error err
+ this.user.is_following = false;
+ }).catch(err => {
+ console.error(err);
}).then(() => {
- this.wait = false
+ this.wait = false;
this.update();
- else
+ });
+ } else {
this.api('following/create', {
user_id: this.user.id
}).then(() => {
- this.user.is_following = true
- .catch (err) ->
- console.error err
+ this.user.is_following = true;
+ }).catch(err => {
+ console.error(err);
}).then(() => {
- this.wait = false
+ this.wait = false;
this.update();
+ });
+ }
+ };
diff --git a/src/web/app/mobile/tags/images-viewer.tag b/src/web/app/mobile/tags/images-viewer.tag
index ad02850e30..f3724f21b6 100644
--- a/src/web/app/mobile/tags/images-viewer.tag
+++ b/src/web/app/mobile/tags/images-viewer.tag
@@ -18,10 +18,11 @@
diff --git a/src/web/app/mobile/tags/index.js b/src/web/app/mobile/tags/index.js
index 2a8f2161c2..dec2be3325 100644
--- a/src/web/app/mobile/tags/index.js
+++ b/src/web/app/mobile/tags/index.js
@@ -1,7 +1,6 @@
require('./ui.tag');
require('./ui-header.tag');
require('./ui-nav.tag');
-require('./stream-indicator.tag');
require('./page/entrance.tag');
require('./page/entrance/signin.tag');
require('./page/entrance/signup.tag');
diff --git a/src/web/app/mobile/tags/notification-preview.tag b/src/web/app/mobile/tags/notification-preview.tag
index 800d1b4345..b93b92d919 100644
--- a/src/web/app/mobile/tags/notification-preview.tag
+++ b/src/web/app/mobile/tags/notification-preview.tag
@@ -108,6 +108,6 @@
diff --git a/src/web/app/mobile/tags/notification.tag b/src/web/app/mobile/tags/notification.tag
index 9cf61fe40e..d32e6b40ae 100644
--- a/src/web/app/mobile/tags/notification.tag
+++ b/src/web/app/mobile/tags/notification.tag
@@ -168,6 +168,6 @@
diff --git a/src/web/app/mobile/tags/notifications.tag b/src/web/app/mobile/tags/notifications.tag
index 9fb695a434..e73877266e 100644
--- a/src/web/app/mobile/tags/notifications.tag
+++ b/src/web/app/mobile/tags/notifications.tag
@@ -61,33 +61,36 @@
this.mixin('stream');
this.mixin('get-post-summary');
- this.notifications = []
- this.loading = true
+ this.notifications = [];
+ this.loading = true;
this.on('mount', () => {
- this.api 'i/notifications'
- }).then((notifications) => {
- this.notifications = notifications
- this.loading = false
- this.update();
- this.trigger('loaded');
- .catch (err, text-status) ->
- console.error err
+ this.api('i/notifications').then(notifications => {
+ this.update({
+ loading: false,
+ notifications: notifications
+ });
+ });
- this.stream.on 'notification' this.on-notification
+ this.stream.on('notification', this.onNotification);
+ });
this.on('unmount', () => {
- this.stream.off 'notification' this.on-notification
+ this.stream.off('notification', this.onNotification);
+ });
- this.on-notification = (notification) => {
- @notifications.unshift notification
+ this.onNotification = notification => {
+ this.notifications.unshift(notification);
this.update();
+ };
this.on('update', () => {
- @notifications.forEach (notification) =>
- date = (new Date notification.created_at).getDate()
- month = (new Date notification.created_at).getMonth() + 1
- notification._date = date
- notification._datetext = month + '月 ' + date + '日'
+ this.notifications.forEach(notification => {
+ const date = new Date(notification.created_at).getDate();
+ const month = new Date(notification.created_at).getMonth() + 1;
+ notification._date = date;
+ notification._datetext = `${month}月 ${date}日`;
+ });
+ });
diff --git a/src/web/app/mobile/tags/notify.tag b/src/web/app/mobile/tags/notify.tag
index 3003528fe4..c97e70696c 100644
--- a/src/web/app/mobile/tags/notify.tag
+++ b/src/web/app/mobile/tags/notify.tag
@@ -18,21 +18,21 @@
diff --git a/src/web/app/mobile/tags/post-detail.tag b/src/web/app/mobile/tags/post-detail.tag
index 2b4bef1da3..e8149e0982 100644
--- a/src/web/app/mobile/tags/post-detail.tag
+++ b/src/web/app/mobile/tags/post-detail.tag
@@ -342,89 +342,111 @@
this.on('mount', () => {
this.api('posts/show', {
post_id: this.opts.post
- }).then((post) => {
- this.post = post
- this.is-repost = this.post.repost?
- this.p = if @is-repost then this.post.repost else this.post
- this.summary = @get-post-summary this.p
+ }).then(post => {
+ const isRepost = post.repost != null;
+ const p = isRepost ? post.repost : post;
+ this.update({
+ fetching: false,
+ post: post,
+ isRepost: isRepost,
+ p: p
+ });
+
this.trigger('loaded');
- this.fetching = false
- this.update();
- if this.p.text?
- tokens = @analyze this.p.text
- this.refs.text.innerHTML = @compile tokens
+ if (this.p.text) {
+ const tokens = this.analyze(this.p.text);
- this.refs.text.children.forEach (e) =>
- if e.tag-name == 'MK-URL'
- riot.mount e
+ this.refs.text.innerHTML = this.compile(tokens);
+
+ this.refs.text.children.forEach(e => {
+ if (e.tagName == 'MK-URL') riot.mount(e);
+ });
// URLをプレビュー
tokens
- .filter (t) -> t.type == 'link'
- .map (t) =>
- this.preview = this.refs.text.appendChild(document.createElement('mk-url-preview'));
- riot.mount this.preview, do
- url: t.content
+ .filter(t => t.type == 'link')
+ .map(t => {
+ riot.mount(this.refs.text.appendChild(document.createElement('mk-url-preview')), {
+ url: t.content
+ });
+ });
+ }
// Get likes
this.api('posts/likes', {
- post_id: this.p.id
+ post_id: this.p.id,
limit: 8
- }).then((likes) => {
- this.likes = likes
- this.update();
+ }).then(likes => {
+ this.update({
+ likes: likes
+ });
+ });
// Get reposts
this.api('posts/reposts', {
- post_id: this.p.id
+ post_id: this.p.id,
limit: 8
- }).then((reposts) => {
- this.reposts = reposts
- this.update();
+ }).then(reposts => {
+ this.update({
+ reposts: reposts
+ });
+ });
// Get replies
this.api('posts/replies', {
- post_id: this.p.id
+ post_id: this.p.id,
limit: 8
- }).then((replies) => {
- this.replies = replies
- this.update();
+ }).then(replies => {
+ this.update({
+ replies: replies
+ });
+ });
+ });
+ });
this.reply = () => {
- this.openPostForm do
+ riot.mount(document.body.appendChild(document.createElement('mk-post-form-window')), {
reply: this.p
+ });
+ };
this.repost = () => {
- text = window.prompt '「' + @summary + '」をRepost'
- if text?
- this.api('posts/create', {
- repost_id: this.p.id
- text: if text == '' then undefined else text
+ riot.mount(document.body.appendChild(document.createElement('mk-repost-form-window')), {
+ post: this.p
+ });
+ };
this.like = () => {
- if this.p.is_liked
+ if (this.p.is_liked) {
this.api('posts/likes/delete', {
post_id: this.p.id
}).then(() => {
- this.p.is_liked = false
+ this.p.is_liked = false;
this.update();
- else
+ });
+ } else {
this.api('posts/likes/create', {
post_id: this.p.id
}).then(() => {
- this.p.is_liked = true
+ this.p.is_liked = true;
this.update();
+ });
+ }
+ };
- this.load-context = () => {
- this.loading-context = true
+ this.loadContext = () => {
+ this.loadingContext = true;
- // Get context
+ // Fetch context
this.api('posts/context', {
post_id: this.p.reply_to_id
- }).then((context) => {
- this.context = context.reverse!
- this.loading-context = false
- this.update();
+ }).then(context => {
+ this.update({
+ loadContext: false,
+ content: context.reverse()
+ });
+ });
+ };
diff --git a/src/web/app/mobile/tags/post-form.tag b/src/web/app/mobile/tags/post-form.tag
index 27c6c005ce..397475e3f5 100644
--- a/src/web/app/mobile/tags/post-form.tag
+++ b/src/web/app/mobile/tags/post-form.tag
@@ -10,7 +10,7 @@