From 73029df58ae7c32ad9cc1e3ff4828e0547635bf3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 22 Feb 2018 02:15:46 +0900 Subject: [PATCH] wip --- src/web/app/common/mios.ts | 5 ++- src/web/app/desktop/api/post.ts | 21 +++++++++++-- src/web/app/mobile/api/notify.ts | 3 ++ src/web/app/mobile/api/post.ts | 31 +++++++++++++++---- src/web/app/mobile/script.ts | 8 ++--- .../app/mobile/views/components/post-form.vue | 2 +- 6 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 src/web/app/mobile/api/notify.ts diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index 4b9375f54..a37c5d6f7 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -42,7 +42,10 @@ export type API = { default?: string; }) => Promise; - post: () => void; + post: (opts?: { + reply?: any; + repost?: any; + }) => void; notify: (message: string) => void; }; diff --git a/src/web/app/desktop/api/post.ts b/src/web/app/desktop/api/post.ts index 4eebd747f..cf49615df 100644 --- a/src/web/app/desktop/api/post.ts +++ b/src/web/app/desktop/api/post.ts @@ -1,6 +1,21 @@ import PostFormWindow from '../views/components/post-form-window.vue'; +import RepostFormWindow from '../views/components/repost-form-window.vue'; -export default function() { - const vm = new PostFormWindow().$mount(); - document.body.appendChild(vm.$el); +export default function(opts) { + const o = opts || {}; + if (o.repost) { + const vm = new RepostFormWindow({ + propsData: { + repost: o.repost + } + }).$mount(); + document.body.appendChild(vm.$el); + } else { + const vm = new PostFormWindow({ + propsData: { + reply: o.reply + } + }).$mount(); + document.body.appendChild(vm.$el); + } } diff --git a/src/web/app/mobile/api/notify.ts b/src/web/app/mobile/api/notify.ts new file mode 100644 index 000000000..82780d196 --- /dev/null +++ b/src/web/app/mobile/api/notify.ts @@ -0,0 +1,3 @@ +export default function(message) { + alert(message); +} diff --git a/src/web/app/mobile/api/post.ts b/src/web/app/mobile/api/post.ts index 11ffc779f..3ceb10496 100644 --- a/src/web/app/mobile/api/post.ts +++ b/src/web/app/mobile/api/post.ts @@ -1,5 +1,9 @@ +import PostForm from '../views/components/post-form.vue'; +import RepostForm from '../views/components/repost-form.vue'; + +export default function(opts) { + const o = opts || {}; -export default opts => { const app = document.getElementById('app'); app.style.display = 'none'; @@ -7,8 +11,23 @@ export default opts => { app.style.display = 'block'; } - const form = riot.mount(document.body.appendChild(document.createElement('mk-post-form')), opts)[0]; - form - .on('cancel', recover) - .on('post', recover); -}; + if (o.repost) { + const vm = new RepostForm({ + propsData: { + repost: o.repost + } + }).$mount(); + vm.$once('cancel', recover); + vm.$once('post', recover); + document.body.appendChild(vm.$el); + } else { + const vm = new PostForm({ + propsData: { + reply: o.reply + } + }).$mount(); + vm.$once('cancel', recover); + vm.$once('post', recover); + document.body.appendChild(vm.$el); + } +} diff --git a/src/web/app/mobile/script.ts b/src/web/app/mobile/script.ts index 339c9a8e4..1d25280d9 100644 --- a/src/web/app/mobile/script.ts +++ b/src/web/app/mobile/script.ts @@ -13,8 +13,6 @@ import dialog from './api/dialog'; import input from './api/input'; import post from './api/post'; import notify from './api/notify'; -import updateAvatar from './api/update-avatar'; -import updateBanner from './api/update-banner'; import MkIndex from './views/pages/index.vue'; import MkUser from './views/pages/user/user.vue'; @@ -35,15 +33,13 @@ init((launch) => { document.body.setAttribute('ontouchstart', ''); // Launch the app - const [app, os] = launch(os => ({ + const [app] = launch(os => ({ chooseDriveFolder, chooseDriveFile, dialog, input, post, - notify, - updateAvatar: updateAvatar(os), - updateBanner: updateBanner(os) + notify })); // Routing diff --git a/src/web/app/mobile/views/components/post-form.vue b/src/web/app/mobile/views/components/post-form.vue index 091056bcd..6c41a73b5 100644 --- a/src/web/app/mobile/views/components/post-form.vue +++ b/src/web/app/mobile/views/components/post-form.vue @@ -25,7 +25,7 @@ -