iceshrimp-161sh/src/client/app/mobile/api/post.ts

44 lines
1.0 KiB
TypeScript
Raw Normal View History

2018-02-21 18:15:46 +01:00
import PostForm from '../views/components/post-form.vue';
2018-04-07 19:30:37 +02:00
//import RenoteForm from '../views/components/renote-form.vue';
import getNoteSummary from '../../../../renderers/get-note-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-04-07 19:30:37 +02:00
if (o.renote) {
/*const vm = new RenoteForm({
2018-02-21 18:15:46 +01:00
propsData: {
2018-04-07 19:30:37 +02:00
renote: o.renote
2018-02-21 18:15:46 +01:00
}
}).$mount();
vm.$once('cancel', recover);
2018-04-07 19:30:37 +02:00
vm.$once('note', recover);
2018-02-21 18:22:10 +01:00
document.body.appendChild(vm.$el);*/
2018-04-07 19:30:37 +02:00
const text = window.prompt(`${getNoteSummary(o.renote)}」をRenote`);
2018-02-21 18:22:10 +01:00
if (text == null) return;
2018-04-07 19:30:37 +02:00
os.api('notes/create', {
renoteId: o.renote.id,
2018-02-21 18:22:10 +01:00
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({
2018-02-27 17:13:42 +01:00
parent: os.app,
2018-02-21 18:15:46 +01:00
propsData: {
reply: o.reply
}
}).$mount();
vm.$once('cancel', recover);
2018-04-07 19:30:37 +02:00
vm.$once('note', recover);
2018-02-21 18:15:46 +01:00
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
};