This commit is contained in:
syuilo 2020-09-20 14:09:51 +09:00
parent 404583a285
commit ea303daf64
2 changed files with 19 additions and 12 deletions

View File

@ -58,7 +58,6 @@ import { faEyeSlash, faLaughSquint } from '@fortawesome/free-regular-svg-icons';
import insertTextAtCursor from 'insert-text-at-cursor'; import insertTextAtCursor from 'insert-text-at-cursor';
import { length } from 'stringz'; import { length } from 'stringz';
import { toASCII } from 'punycode'; import { toASCII } from 'punycode';
import MkVisibilityChooser from './visibility-chooser.vue';
import MkUserSelect from './user-select.vue'; import MkUserSelect from './user-select.vue';
import XNotePreview from './note-preview.vue'; import XNotePreview from './note-preview.vue';
import { parse } from '../../mfm/parse'; import { parse } from '../../mfm/parse';
@ -419,18 +418,23 @@ export default defineComponent({
this.saveDraft(); this.saveDraft();
}, },
setVisibility() { async setVisibility() {
if (this.channel) { if (this.channel) {
// TODO: information dialog // TODO: information dialog
return; return;
} }
os.modal(MkVisibilityChooser, { os.modal(await import('./visibility-chooser.vue'), {
source: this.$refs.visibilityButton,
currentVisibility: this.visibility, currentVisibility: this.visibility,
currentLocalOnly: this.localOnly currentLocalOnly: this.localOnly
}).then(({ visibility, localOnly }) => { }, {
this.applyVisibility(visibility); 'change-visibility': visibility => {
this.localOnly = localOnly; this.applyVisibility(visibility);
},
'change-local-only': localOnly => {
this.localOnly = localOnly;
}
}, {
source: this.$refs.visibilityButton
}); });
}, },

View File

@ -46,11 +46,7 @@ import { faGlobe, faUnlock, faHome, faBiohazard, faToggleOn, faToggleOff } from
import { faEnvelope } from '@fortawesome/free-regular-svg-icons'; import { faEnvelope } from '@fortawesome/free-regular-svg-icons';
export default defineComponent({ export default defineComponent({
emits: ['done'],
props: { props: {
source: {
required: true
},
currentVisibility: { currentVisibility: {
type: String, type: String,
required: false required: false
@ -60,6 +56,7 @@ export default defineComponent({
required: false required: false
} }
}, },
emits: ['done', 'change-visibility', 'change-local-only'],
data() { data() {
return { return {
v: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : (this.currentVisibility || this.$store.state.settings.defaultNoteVisibility), 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 faGlobe, faUnlock, faEnvelope, faHome, faBiohazard, faToggleOn, faToggleOff
} }
}, },
watch: {
localOnly() {
this.$emit('change-local-only', this.localOnly);
}
},
methods: { methods: {
choose(visibility) { choose(visibility) {
if (this.$store.state.settings.rememberNoteVisibility) { if (this.$store.state.settings.rememberNoteVisibility) {
this.$store.commit('deviceUser/setVisibility', visibility); this.$store.commit('deviceUser/setVisibility', visibility);
} }
this.$emit('done', { visibility, localOnly: this.localOnly }); this.$emit('change-visibility', visibility);
this.$emit('done');
}, },
} }
}); });