デフォルト公開範囲が機能していない問題を修正

This commit is contained in:
syuilo 2020-10-19 14:46:55 +09:00
parent a755dd5f9e
commit 190d1bbf3c
3 changed files with 29 additions and 38 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<MkModal ref="modal" @click="$refs.modal.close()" @closed="$emit('closed')" :position="'top'"> <MkModal ref="modal" @click="$refs.modal.close()" @closed="$emit('closed')" :position="'top'">
<MkPostForm @done="$refs.modal.close()" @esc="$refs.modal.close()" v-bind="$attrs"/> <MkPostForm @posted="$refs.modal.close()" @cancel="$refs.modal.close()" @esc="$refs.modal.close()" v-bind="$attrs"/>
</MkModal> </MkModal>
</template> </template>

View file

@ -125,7 +125,7 @@ export default defineComponent({
}, },
}, },
emits: ['posted', 'done', 'esc'], emits: ['posted', 'cancel', 'esc'],
data() { data() {
return { return {
@ -135,8 +135,8 @@ export default defineComponent({
poll: null, poll: null,
useCw: false, useCw: false,
cw: null, cw: null,
localOnly: false, localOnly: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.localOnly : this.$store.state.settings.defaultNoteLocalOnly,
visibility: 'public', visibility: this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : this.$store.state.settings.defaultNoteVisibility,
visibleUsers: [], visibleUsers: [],
autocomplete: null, autocomplete: null,
draghover: false, draghover: false,
@ -202,12 +202,6 @@ export default defineComponent({
} }
}, },
watch: {
localOnly() {
this.$store.commit('deviceUser/setLocalOnly', this.localOnly);
}
},
mounted() { mounted() {
if (this.initialText) { if (this.initialText) {
this.text = this.initialText; this.text = this.initialText;
@ -239,11 +233,9 @@ export default defineComponent({
} }
} }
// if (this.channel) {
if (this.channel == null) { this.visibility = 'public';
this.applyVisibility(this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.visibility : this.$store.state.settings.defaultNoteVisibility); this.localOnly = true; // TODO:
this.localOnly = this.$store.state.settings.rememberNoteVisibility ? this.$store.state.deviceUser.localOnly : this.$store.state.settings.defaultNoteLocalOnly;
} }
// //
@ -295,7 +287,7 @@ export default defineComponent({
this.text = draft.data.text; this.text = draft.data.text;
this.useCw = draft.data.useCw; this.useCw = draft.data.useCw;
this.cw = draft.data.cw; this.cw = draft.data.cw;
this.applyVisibility(draft.data.visibility); this.visibility = draft.data.visibility;
this.localOnly = draft.data.localOnly; this.localOnly = draft.data.localOnly;
this.files = (draft.data.files || []).filter(e => e); this.files = (draft.data.files || []).filter(e => e);
if (draft.data.poll) { if (draft.data.poll) {
@ -398,18 +390,20 @@ export default defineComponent({
src: this.$refs.visibilityButton src: this.$refs.visibilityButton
}, { }, {
changeVisibility: visibility => { changeVisibility: visibility => {
this.applyVisibility(visibility); this.visibility = visibility;
if (this.$store.state.settings.rememberNoteVisibility) {
this.$store.commit('deviceUser/setVisibility', visibility);
}
}, },
changeLocalOnly: localOnly => { changeLocalOnly: localOnly => {
this.localOnly = localOnly; this.localOnly = localOnly;
if (this.$store.state.settings.rememberNoteVisibility) {
this.$store.commit('deviceUser/setLocalOnly', localOnly);
}
} }
}, 'closed'); }, 'closed');
}, },
applyVisibility(v: string) {
this.visibility = (noteVisibilities as unknown as string[]).includes(v) ? v : 'public'; // v11
},
addVisibleUser() { addVisibleUser() {
os.selectUser().then(user => { os.selectUser().then(user => {
this.visibleUsers.push(user); this.visibleUsers.push(user);
@ -556,23 +550,23 @@ export default defineComponent({
this.posting = true; this.posting = true;
os.api('notes/create', data).then(() => { os.api('notes/create', data).then(() => {
this.clear(); this.clear();
this.deleteDraft(); this.$nextTick(() => {
this.$emit('posted'); 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 => { }).catch(err => {
}).then(() => {
this.posting = false; 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() { cancel() {
this.$emit('done'); this.$emit('cancel');
}, },
insertMention() { insertMention() {

View file

@ -55,11 +55,11 @@ export default defineComponent({
props: { props: {
currentVisibility: { currentVisibility: {
type: String, type: String,
required: false required: true
}, },
currentLocalOnly: { currentLocalOnly: {
type: Boolean, type: Boolean,
required: false required: true
}, },
src: { src: {
required: false required: false
@ -68,7 +68,7 @@ export default defineComponent({
emits: ['change-visibility', 'change-local-only', 'closed'], emits: ['change-visibility', 'change-local-only', 'closed'],
data() { data() {
return { 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, localOnly: this.currentLocalOnly,
faGlobe, faUnlock, faEnvelope, faHome, faBiohazard, faToggleOn, faToggleOff faGlobe, faUnlock, faEnvelope, faHome, faBiohazard, faToggleOn, faToggleOff
} }
@ -81,9 +81,6 @@ export default defineComponent({
methods: { methods: {
choose(visibility) { choose(visibility) {
this.v = visibility; this.v = visibility;
if (this.$store.state.settings.rememberNoteVisibility) {
this.$store.commit('deviceUser/setVisibility', visibility);
}
this.$emit('change-visibility', visibility); this.$emit('change-visibility', visibility);
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.modal.close(); this.$refs.modal.close();