2018-02-21 18:15:46 +01:00
|
|
|
import PostForm from '../views/components/post-form.vue';
|
2018-02-21 18:22:10 +01:00
|
|
|
//import RepostForm from '../views/components/repost-form.vue';
|
|
|
|
import getPostSummary from '../../../../common/get-post-summary';
|
2018-02-21 18:15:46 +01:00
|
|
|
|
2018-02-21 18:22:10 +01:00
|
|
|
export default (os) => (opts) => {
|
2018-02-21 18:15:46 +01:00
|
|
|
const o = opts || {};
|
2018-02-21 18:00:30 +01:00
|
|
|
|
2018-02-21 18:15:46 +01:00
|
|
|
if (o.repost) {
|
2018-02-21 18:22:10 +01:00
|
|
|
/*const vm = new RepostForm({
|
2018-02-21 18:15:46 +01:00
|
|
|
propsData: {
|
|
|
|
repost: o.repost
|
|
|
|
}
|
|
|
|
}).$mount();
|
|
|
|
vm.$once('cancel', recover);
|
|
|
|
vm.$once('post', recover);
|
2018-02-21 18:22:10 +01:00
|
|
|
document.body.appendChild(vm.$el);*/
|
|
|
|
|
|
|
|
const text = window.prompt(`「${getPostSummary(o.repost)}」をRepost`);
|
|
|
|
if (text == null) return;
|
|
|
|
os.api('posts/create', {
|
|
|
|
repost_id: o.repost.id,
|
|
|
|
text: text == '' ? undefined : text
|
|
|
|
});
|
2018-02-21 18:15:46 +01:00
|
|
|
} else {
|
2018-02-21 18:22:10 +01:00
|
|
|
const app = document.getElementById('app');
|
|
|
|
app.style.display = 'none';
|
|
|
|
|
|
|
|
function recover() {
|
|
|
|
app.style.display = 'block';
|
|
|
|
}
|
|
|
|
|
2018-02-21 18:15:46 +01:00
|
|
|
const vm = new PostForm({
|
|
|
|
propsData: {
|
|
|
|
reply: o.reply
|
|
|
|
}
|
|
|
|
}).$mount();
|
|
|
|
vm.$once('cancel', recover);
|
|
|
|
vm.$once('post', recover);
|
|
|
|
document.body.appendChild(vm.$el);
|
2018-02-22 21:43:19 +01:00
|
|
|
(vm as any).focus();
|
2018-02-21 18:15:46 +01:00
|
|
|
}
|
2018-02-21 18:22:10 +01:00
|
|
|
};
|