diff --git a/src/client/components/post-form-dialog.vue b/src/client/components/post-form-dialog.vue index f2563a9be..ae1cd7f01 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 ba7770345..ccca4b54a 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 06901378b..f0cff5db6 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();