デフォルト公開範囲が機能していない問題を修正
This commit is contained in:
		
							parent
							
								
									a755dd5f9e
								
							
						
					
					
						commit
						190d1bbf3c
					
				|  | @ -1,6 +1,6 @@ | |||
| <template> | ||||
| <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> | ||||
| </template> | ||||
| 
 | ||||
|  |  | |||
|  | @ -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() { | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue