From 2a1fab34df0ae5a6e8bdaf5cd731ae50545328b6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 01:05:23 +0900 Subject: [PATCH] wip --- src/web/app/auth/tags/form.tag | 12 +- src/web/app/auth/tags/index.tag | 62 +-- src/web/app/common/tags/core-error.tag | 7 +- src/web/app/common/tags/index.js | 2 +- src/web/app/common/tags/ripple-string.tag | 26 -- .../tags/stream-indicator.tag | 17 +- src/web/app/desktop/tags/index.js | 1 - src/web/app/desktop/tags/post-form.tag | 1 + src/web/app/dev/tags/new-app-form.tag | 105 ++--- src/web/app/dev/tags/pages/app.tag | 14 +- src/web/app/dev/tags/pages/apps.tag | 13 +- src/web/app/dev/tags/pages/index.tag | 5 - src/web/app/mobile/tags/drive.tag | 366 +++++++++--------- src/web/app/mobile/tags/drive/file-viewer.tag | 21 +- src/web/app/mobile/tags/drive/file.tag | 14 +- src/web/app/mobile/tags/drive/folder.tag | 7 +- src/web/app/mobile/tags/follow-button.tag | 78 ++-- src/web/app/mobile/tags/images-viewer.tag | 7 +- src/web/app/mobile/tags/index.js | 1 - .../app/mobile/tags/notification-preview.tag | 2 +- src/web/app/mobile/tags/notification.tag | 2 +- src/web/app/mobile/tags/notifications.tag | 41 +- src/web/app/mobile/tags/notify.tag | 24 +- src/web/app/mobile/tags/post-detail.tag | 116 +++--- src/web/app/mobile/tags/post-form.tag | 134 ++++--- src/web/app/mobile/tags/search-posts.tag | 12 +- src/web/app/mobile/tags/search.tag | 5 +- src/web/app/mobile/tags/stream-indicator.tag | 54 --- src/web/app/mobile/tags/sub-post-content.tag | 16 +- src/web/app/mobile/tags/timeline-post.tag | 2 +- src/web/app/mobile/tags/ui-header.tag | 6 +- src/web/app/mobile/tags/ui-nav.tag | 10 +- src/web/app/mobile/tags/ui.tag | 41 +- src/web/app/mobile/tags/user-followers.tag | 15 +- src/web/app/mobile/tags/user-following.tag | 15 +- src/web/app/mobile/tags/user-timeline.tag | 18 +- src/web/app/mobile/tags/users-list.tag | 67 ++-- 37 files changed, 680 insertions(+), 659 deletions(-) delete mode 100644 src/web/app/common/tags/ripple-string.tag rename src/web/app/{desktop => common}/tags/stream-indicator.tag (70%) delete mode 100644 src/web/app/mobile/tags/stream-indicator.tag diff --git a/src/web/app/auth/tags/form.tag b/src/web/app/auth/tags/form.tag index 619c71065e..4a236f7594 100644 --- a/src/web/app/auth/tags/form.tag +++ b/src/web/app/auth/tags/form.tag @@ -108,19 +108,23 @@ diff --git a/src/web/app/auth/tags/index.tag b/src/web/app/auth/tags/index.tag index e52aeed4d2..f80e9dd1bc 100644 --- a/src/web/app/auth/tags/index.tag +++ b/src/web/app/auth/tags/index.tag @@ -91,47 +91,57 @@ this.mixin('i'); this.mixin('api'); - this.state = null - this.fetching = true + this.state = null; + this.fetching = true; - this.token = window.location.href.split '/' .pop! + this.token = window.location.href.split('/').pop(); this.on('mount', () => { - if not this.SIGNIN then return + if (!this.SIGNIN) return; // Fetch session this.api('auth/session/show', { - token: @token - }).then((session) => { - this.session = session - this.fetching = false + token: this.token + }).then(session => { + this.session = session; + this.fetching = false; // 既に連携していた場合 - if @session.app.is_authorized + if (this.session.app.is_authorized) { this.api('auth/accept', { - token: @session.token + token: this.session.token }).then(() => { - @accepted! - else - this.state = 'waiting' - this.update(); + this.accepted(); + }); + } else { + this.update({ + state: 'waiting' + }); this.refs.form.on('denied', () => { - this.state = 'denied' - this.update(); + this.update({ + state: 'denied' + }); + }); - this.refs.form.on 'accepted' @accepted - - .catch (error) => - this.fetching = false - this.state = 'fetch-session-error' - this.update(); + this.refs.form.on('accepted', this.accepted); + } + }).catch(error => { + this.update({ + fetching: false, + state: 'fetch-session-error' + }); + }); + }); this.accepted = () => { - this.state = 'accepted' - this.update(); + this.update({ + state: 'accepted' + }); - if @session.app.callback_url - location.href = @session.app.callback_url + '?token=' + @session.token + if (this.session.app.callback_url) { + location.href = this.session.app.callback_url + '?token=' + this.session.token; + } + }; diff --git a/src/web/app/common/tags/core-error.tag b/src/web/app/common/tags/core-error.tag index e74e205afd..feac70fbea 100644 --- a/src/web/app/common/tags/core-error.tag +++ b/src/web/app/common/tags/core-error.tag @@ -1,8 +1,7 @@ - -

- サーバーに接続できません -

+ + +

サーバーに接続できません

インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから再度お試しください。

いつもMisskeyをご利用いただきありがとうございます。

- - diff --git a/src/web/app/desktop/tags/stream-indicator.tag b/src/web/app/common/tags/stream-indicator.tag similarity index 70% rename from src/web/app/desktop/tags/stream-indicator.tag rename to src/web/app/common/tags/stream-indicator.tag index 6192b642f3..7d343a438a 100644 --- a/src/web/app/desktop/tags/stream-indicator.tag +++ b/src/web/app/common/tags/stream-indicator.tag @@ -1,9 +1,16 @@ -

接続中 -

-

切断されました 接続中 -

-

接続完了

+

+ + 接続中 +

+

+ + 切断されました 接続中 +

+

+ + 接続完了 +

diff --git a/src/web/app/dev/tags/pages/apps.tag b/src/web/app/dev/tags/pages/apps.tag index c87141711f..43db70fcf2 100644 --- a/src/web/app/dev/tags/pages/apps.tag +++ b/src/web/app/dev/tags/pages/apps.tag @@ -13,18 +13,21 @@ diff --git a/src/web/app/dev/tags/pages/index.tag b/src/web/app/dev/tags/pages/index.tag index ff2494212c..f863876fa7 100644 --- a/src/web/app/dev/tags/pages/index.tag +++ b/src/web/app/dev/tags/pages/index.tag @@ -2,10 +2,5 @@ diff --git a/src/web/app/mobile/tags/drive.tag b/src/web/app/mobile/tags/drive.tag index 36c037d1a9..707ec9478e 100644 --- a/src/web/app/mobile/tags/drive.tag +++ b/src/web/app/mobile/tags/drive.tag @@ -3,7 +3,7 @@

ドライブ

-

{ folder.name }

+

{ folder.name }

@@ -14,7 +14,7 @@

{ file.name }

-
+
0 }> @@ -27,11 +27,11 @@

もっと読み込む

-
+

ドライブには何もありません。

このフォルダーは空です

-
+
@@ -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 @@
- +
  • @@ -182,103 +182,111 @@ diff --git a/src/web/app/mobile/tags/search-posts.tag b/src/web/app/mobile/tags/search-posts.tag index 2dbb162d7b..b0efe14636 100644 --- a/src/web/app/mobile/tags/search-posts.tag +++ b/src/web/app/mobile/tags/search-posts.tag @@ -15,18 +15,22 @@ this.query = this.opts.query; this.withMedia = this.opts.withMedia; - this.init = new Promise (res, rej) => + this.init = new Promise((res, rej) => { this.api('posts/search', { query: this.query }).then(posts => { - res posts + res(posts); this.trigger('loaded'); + }); + }); this.more = () => { this.offset += this.max; this.api('posts/search', { - query: this.query - max: this.max + query: this.query, + max: this.max, offset: this.offset + }); + }; diff --git a/src/web/app/mobile/tags/search.tag b/src/web/app/mobile/tags/search.tag index ab7ba4fd26..831e5a3e34 100644 --- a/src/web/app/mobile/tags/search.tag +++ b/src/web/app/mobile/tags/search.tag @@ -3,13 +3,14 @@ diff --git a/src/web/app/mobile/tags/stream-indicator.tag b/src/web/app/mobile/tags/stream-indicator.tag deleted file mode 100644 index 9ca311c479..0000000000 --- a/src/web/app/mobile/tags/stream-indicator.tag +++ /dev/null @@ -1,54 +0,0 @@ - -

    接続中 -

    -

    切断されました 接続中 -

    -

    接続完了

    - - -
    diff --git a/src/web/app/mobile/tags/sub-post-content.tag b/src/web/app/mobile/tags/sub-post-content.tag index a5af90cc74..5ff01c5020 100644 --- a/src/web/app/mobile/tags/sub-post-content.tag +++ b/src/web/app/mobile/tags/sub-post-content.tag @@ -30,15 +30,17 @@ diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag index a19fca7fcd..0a6db9a92d 100644 --- a/src/web/app/mobile/tags/timeline-post.tag +++ b/src/web/app/mobile/tags/timeline-post.tag @@ -344,7 +344,7 @@ }; this.like = () => { - if (this.p.is_liked) + if (this.p.is_liked) { this.api('posts/likes/delete', { post_id: this.p.id }).then(() => { diff --git a/src/web/app/mobile/tags/ui-header.tag b/src/web/app/mobile/tags/ui-header.tag index 405db1897f..30259ba911 100644 --- a/src/web/app/mobile/tags/ui-header.tag +++ b/src/web/app/mobile/tags/ui-header.tag @@ -13,7 +13,7 @@ $height = 48px display block - position fixed + position sticky top 0 z-index 1024 width 100% @@ -91,10 +91,6 @@ this.mixin('ui'); this.mixin('open-post-form'); - this.on('mount', () => { - this.opts.ready(); - }); - this.ui.on('title', title => { if (this.refs.title) this.refs.title.innerHTML = title; }); diff --git a/src/web/app/mobile/tags/ui-nav.tag b/src/web/app/mobile/tags/ui-nav.tag index d8769d9c06..23d07efdc4 100644 --- a/src/web/app/mobile/tags/ui-nav.tag +++ b/src/web/app/mobile/tags/ui-nav.tag @@ -120,12 +120,10 @@ this.mixin('i'); this.mixin('page'); - this.on('mount', () => { - this.opts.ready! - this.search = () => { - query = window.prompt '検索' - if query? and query != '' - this.page '/search:' + query + const query = window.prompt('検索'); + if (query == null || query == '') return; + this.page('/search:' + query); + }; diff --git a/src/web/app/mobile/tags/ui.tag b/src/web/app/mobile/tags/ui.tag index ca6ac3f55c..3b3c6823d0 100644 --- a/src/web/app/mobile/tags/ui.tag +++ b/src/web/app/mobile/tags/ui.tag @@ -1,7 +1,7 @@
    - - + +
    @@ -16,36 +16,25 @@
    diff --git a/src/web/app/mobile/tags/user-followers.tag b/src/web/app/mobile/tags/user-followers.tag index eecf09cab8..3a1fc1d4b9 100644 --- a/src/web/app/mobile/tags/user-followers.tag +++ b/src/web/app/mobile/tags/user-followers.tag @@ -8,18 +8,21 @@ diff --git a/src/web/app/mobile/tags/user-following.tag b/src/web/app/mobile/tags/user-following.tag index b214789aa9..778eb08e1c 100644 --- a/src/web/app/mobile/tags/user-following.tag +++ b/src/web/app/mobile/tags/user-following.tag @@ -8,18 +8,21 @@ diff --git a/src/web/app/mobile/tags/user-timeline.tag b/src/web/app/mobile/tags/user-timeline.tag index 71fb1ac272..fb316dbdf9 100644 --- a/src/web/app/mobile/tags/user-timeline.tag +++ b/src/web/app/mobile/tags/user-timeline.tag @@ -14,18 +14,22 @@ this.user = this.opts.user; this.withMedia = this.opts.withMedia; - this.init = new Promise (res, rej) => + this.init = new Promise((res, rej) => { this.api('users/posts', { - user_id: this.user.id - with_media: @withMedia + user_id: this.user.id, + with_media: this.withMedia }).then(posts => { - res posts + res(posts); this.trigger('loaded'); + }); + }); this.more = () => { this.api('users/posts', { - user_id: this.user.id - with_media: this.withMedia - max_id: this.refs.timeline.tail!.id + user_id: this.user.id, + with_media: this.withMedia, + max_id: this.refs.timeline.tail().id + }); + }; diff --git a/src/web/app/mobile/tags/users-list.tag b/src/web/app/mobile/tags/users-list.tag index ef225d5b5d..82dfa3df45 100644 --- a/src/web/app/mobile/tags/users-list.tag +++ b/src/web/app/mobile/tags/users-list.tag @@ -72,45 +72,48 @@