diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index cade01efab..0df21e5928 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -58,7 +58,6 @@ import { faEyeSlash, faLaughSquint } from '@fortawesome/free-regular-svg-icons'; import insertTextAtCursor from 'insert-text-at-cursor'; import { length } from 'stringz'; import { toASCII } from 'punycode'; -import MkVisibilityChooser from './visibility-chooser.vue'; import MkUserSelect from './user-select.vue'; import XNotePreview from './note-preview.vue'; import { parse } from '../../mfm/parse'; @@ -419,18 +418,23 @@ export default defineComponent({ this.saveDraft(); }, - setVisibility() { + async setVisibility() { if (this.channel) { // TODO: information dialog return; } - os.modal(MkVisibilityChooser, { - source: this.$refs.visibilityButton, + os.modal(await import('./visibility-chooser.vue'), { currentVisibility: this.visibility, currentLocalOnly: this.localOnly - }).then(({ visibility, localOnly }) => { - this.applyVisibility(visibility); - this.localOnly = localOnly; + }, { + 'change-visibility': visibility => { + this.applyVisibility(visibility); + }, + 'change-local-only': localOnly => { + this.localOnly = localOnly; + } + }, { + source: this.$refs.visibilityButton }); }, diff --git a/src/client/components/visibility-chooser.vue b/src/client/components/visibility-chooser.vue index 1dac289545..b15d648dd5 100644 --- a/src/client/components/visibility-chooser.vue +++ b/src/client/components/visibility-chooser.vue @@ -46,11 +46,7 @@ import { faGlobe, faUnlock, faHome, faBiohazard, faToggleOn, faToggleOff } from import { faEnvelope } from '@fortawesome/free-regular-svg-icons'; export default defineComponent({ - emits: ['done'], props: { - source: { - required: true - }, currentVisibility: { type: String, required: false @@ -60,6 +56,7 @@ export default defineComponent({ required: false } }, + emits: ['done', 'change-visibility', 'change-local-only'], data() { return { v: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : (this.currentVisibility || this.$store.state.settings.defaultNoteVisibility), @@ -67,12 +64,18 @@ export default defineComponent({ faGlobe, faUnlock, faEnvelope, faHome, faBiohazard, faToggleOn, faToggleOff } }, + watch: { + localOnly() { + this.$emit('change-local-only', this.localOnly); + } + }, methods: { choose(visibility) { if (this.$store.state.settings.rememberNoteVisibility) { this.$store.commit('deviceUser/setVisibility', visibility); } - this.$emit('done', { visibility, localOnly: this.localOnly }); + this.$emit('change-visibility', visibility); + this.$emit('done'); }, } });