wip #258
This commit is contained in:
parent
a67758e5af
commit
0cab127a58
|
@ -333,6 +333,12 @@
|
||||||
|
|
||||||
this.autocomplete = new this.Autocomplete(this.refs.text);
|
this.autocomplete = new this.Autocomplete(this.refs.text);
|
||||||
this.autocomplete.attach();
|
this.autocomplete.attach();
|
||||||
|
|
||||||
|
let draft = localStorage.getItem('post-draft');
|
||||||
|
if (draft) {
|
||||||
|
draft = JSON.parse(draft);
|
||||||
|
this.refs.text.value = draft.text;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('unmount', () => {
|
this.on('unmount', () => {
|
||||||
|
@ -446,6 +452,7 @@
|
||||||
reply_to_id: this.inReplyToPost ? this.inReplyToPost.id : undefined,
|
reply_to_id: this.inReplyToPost ? this.inReplyToPost.id : undefined,
|
||||||
poll: this.poll ? this.refs.poll.get() : undefined
|
poll: this.poll ? this.refs.poll.get() : undefined
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
|
localStorage.removeItem('post-draft');
|
||||||
this.trigger('post');
|
this.trigger('post');
|
||||||
this.notify(this.inReplyToPost ? '返信しました!' : '投稿しました!');
|
this.notify(this.inReplyToPost ? '返信しました!' : '投稿しました!');
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
@ -460,5 +467,19 @@
|
||||||
this.cat = () => {
|
this.cat = () => {
|
||||||
this.refs.text.value += getCat();
|
this.refs.text.value += getCat();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.on('update', () => {
|
||||||
|
this.save();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.save = () => {
|
||||||
|
const context = {
|
||||||
|
text: this.refs.text.value,
|
||||||
|
files: this.files,
|
||||||
|
poll: this.poll ? this.refs.poll.get() : undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
localStorage.setItem('post-draft', JSON.stringify(context));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
</mk-post-form>
|
</mk-post-form>
|
||||||
|
|
Loading…
Reference in a new issue