From 190d1bbf3c5aadc2d929c99056928b33e4834d5a Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 19 Oct 2020 14:46:55 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88?= =?UTF-8?q?=E5=85=AC=E9=96=8B=E7=AF=84=E5=9B=B2=E3=81=8C=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/post-form-dialog.vue | 2 +- src/client/components/post-form.vue | 56 +++++++++------------ src/client/components/visibility-picker.vue | 9 ++-- 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/src/client/components/post-form-dialog.vue b/src/client/components/post-form-dialog.vue index f2563a9bec..ae1cd7f01e 100644 --- a/src/client/components/post-form-dialog.vue +++ b/src/client/components/post-form-dialog.vue @@ -1,6 +1,6 @@ diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index ba7770345a..ccca4b54a6 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -125,7 +125,7 @@ export default defineComponent({ }, }, - emits: ['posted', 'done', 'esc'], + emits: ['posted', 'cancel', 'esc'], data() { return { @@ -135,8 +135,8 @@ export default defineComponent({ poll: null, useCw: false, cw: null, - localOnly: false, - visibility: 'public', + localOnly: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.localOnly : this.$store.state.settings.defaultNoteLocalOnly, + visibility: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : this.$store.state.settings.defaultNoteVisibility, visibleUsers: [], autocomplete: null, draghover: false, @@ -202,12 +202,6 @@ export default defineComponent({ } }, - watch: { - localOnly() { - this.$store.commit('deviceUser/setLocalOnly', this.localOnly); - } - }, - mounted() { if (this.initialText) { this.text = this.initialText; @@ -239,11 +233,9 @@ export default defineComponent({ } } - // デフォルト公開範囲 - if (this.channel == null) { - this.applyVisibility(this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : this.$store.state.settings.defaultNoteVisibility); - - this.localOnly = this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.localOnly : this.$store.state.settings.defaultNoteLocalOnly; + if (this.channel) { + this.visibility = 'public'; + this.localOnly = true; // TODO: チャンネルが連合するようになった折には消す } // 公開以外へのリプライ時は元の公開範囲を引き継ぐ @@ -295,7 +287,7 @@ export default defineComponent({ this.text = draft.data.text; this.useCw = draft.data.useCw; this.cw = draft.data.cw; - this.applyVisibility(draft.data.visibility); + this.visibility = draft.data.visibility; this.localOnly = draft.data.localOnly; this.files = (draft.data.files || []).filter(e => e); if (draft.data.poll) { @@ -398,18 +390,20 @@ export default defineComponent({ src: this.$refs.visibilityButton }, { changeVisibility: visibility => { - this.applyVisibility(visibility); + this.visibility = visibility; + if (this.$store.state.settings.rememberNoteVisibility) { + this.$store.commit('deviceUser/setVisibility', visibility); + } }, changeLocalOnly: localOnly => { this.localOnly = localOnly; + if (this.$store.state.settings.rememberNoteVisibility) { + this.$store.commit('deviceUser/setLocalOnly', localOnly); + } } }, 'closed'); }, - applyVisibility(v: string) { - this.visibility = (noteVisibilities as unknown as string[]).includes(v) ? v : 'public'; // v11互換性のため - }, - addVisibleUser() { os.selectUser().then(user => { this.visibleUsers.push(user); @@ -556,23 +550,23 @@ export default defineComponent({ this.posting = true; os.api('notes/create', data).then(() => { this.clear(); - this.deleteDraft(); - this.$emit('posted'); + this.$nextTick(() => { + this.deleteDraft(); + this.$emit('posted'); + if (this.text && this.text != '') { + const hashtags = parse(this.text).filter(x => x.node.type === 'hashtag').map(x => x.node.props.hashtag); + const history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[]; + localStorage.setItem('hashtags', JSON.stringify(unique(hashtags.concat(history)))); + } + this.posting = false; + }); }).catch(err => { - }).then(() => { this.posting = false; - this.$emit('done'); }); - - if (this.text && this.text != '') { - const hashtags = parse(this.text).filter(x => x.node.type === 'hashtag').map(x => x.node.props.hashtag); - const history = JSON.parse(localStorage.getItem('hashtags') || '[]') as string[]; - localStorage.setItem('hashtags', JSON.stringify(unique(hashtags.concat(history)))); - } }, cancel() { - this.$emit('done'); + this.$emit('cancel'); }, insertMention() { diff --git a/src/client/components/visibility-picker.vue b/src/client/components/visibility-picker.vue index 06901378b7..f0cff5db63 100644 --- a/src/client/components/visibility-picker.vue +++ b/src/client/components/visibility-picker.vue @@ -55,11 +55,11 @@ export default defineComponent({ props: { currentVisibility: { type: String, - required: false + required: true }, currentLocalOnly: { type: Boolean, - required: false + required: true }, src: { required: false @@ -68,7 +68,7 @@ export default defineComponent({ emits: ['change-visibility', 'change-local-only', 'closed'], data() { return { - v: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : (this.currentVisibility || this.$store.state.settings.defaultNoteVisibility), + v: this.currentVisibility, localOnly: this.currentLocalOnly, faGlobe, faUnlock, faEnvelope, faHome, faBiohazard, faToggleOn, faToggleOff } @@ -81,9 +81,6 @@ export default defineComponent({ methods: { choose(visibility) { this.v = visibility; - if (this.$store.state.settings.rememberNoteVisibility) { - this.$store.commit('deviceUser/setVisibility', visibility); - } this.$emit('change-visibility', visibility); this.$nextTick(() => { this.$refs.modal.close();