tweak note component
This commit is contained in:
		
							parent
							
								
									8709574f3d
								
							
						
					
					
						commit
						c550dafb81
					
				
					 4 changed files with 124 additions and 112 deletions
				
			
		|  | @ -251,17 +251,18 @@ onBeforeUnmount(() => { | |||
| 				color: #fff; | ||||
| 
 | ||||
| 				&:before { | ||||
| 					background: #d42e2e; | ||||
| 					background: #d42e2e !important; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		&:active, | ||||
| 		&.active { | ||||
| 			color: var(--fgOnAccent); | ||||
| 			color: var(--fgOnAccent) !important; | ||||
| 			opacity: 1; | ||||
| 
 | ||||
| 			&:before { | ||||
| 				background: var(--accent); | ||||
| 				background: var(--accent) !important; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
|  | @ -75,14 +75,26 @@ | |||
| 					<i class="ti ti-arrow-back-up"></i> | ||||
| 					<p v-if="appearNote.repliesCount > 0" class="count">{{ appearNote.repliesCount }}</p> | ||||
| 				</button> | ||||
| 				<MkRenoteButton ref="renoteButton" class="button" :note="appearNote" :count="appearNote.renoteCount"/> | ||||
| 				<button v-if="appearNote.myReaction == null" ref="reactButton" class="button _button" @click="react()"> | ||||
| 				<button | ||||
| 					v-if="canRenote" | ||||
| 					ref="renoteButton" | ||||
| 					class="button _button" | ||||
| 					@click="renote()" | ||||
| 					@mousedown="renote()" | ||||
| 				> | ||||
| 					<i class="ti ti-repeat"></i> | ||||
| 					<p v-if="appearNote.renoteCount > 0" class="count">{{ appearNote.renoteCount }}</p> | ||||
| 				</button> | ||||
| 				<button v-else class="button _button" disabled> | ||||
| 					<i class="ti ti-ban"></i> | ||||
| 				</button> | ||||
| 				<button v-if="appearNote.myReaction == null" ref="reactButton" class="button _button" @click="react()" @mousedown="react()"> | ||||
| 					<i class="ti ti-plus"></i> | ||||
| 				</button> | ||||
| 				<button v-if="appearNote.myReaction != null" ref="reactButton" class="button _button reacted" @click="undoReact(appearNote)"> | ||||
| 					<i class="ti ti-minus"></i> | ||||
| 				</button> | ||||
| 				<button ref="menuButton" class="button _button" @click="menu()"> | ||||
| 				<button ref="menuButton" class="button _button" @click="menu()" @mousedown="menu()"> | ||||
| 					<i class="ti ti-dots"></i> | ||||
| 				</button> | ||||
| 			</footer> | ||||
|  | @ -111,7 +123,7 @@ import MkReactionsViewer from '@/components/MkReactionsViewer.vue'; | |||
| import MkMediaList from '@/components/MkMediaList.vue'; | ||||
| import MkCwButton from '@/components/MkCwButton.vue'; | ||||
| import MkPoll from '@/components/MkPoll.vue'; | ||||
| import MkRenoteButton from '@/components/MkRenoteButton.vue'; | ||||
| import MkUsersTooltip from '@/components/MkUsersTooltip.vue'; | ||||
| import MkUrlPreview from '@/components/MkUrlPreview.vue'; | ||||
| import MkInstanceTicker from '@/components/MkInstanceTicker.vue'; | ||||
| import MkVisibility from '@/components/MkVisibility.vue'; | ||||
|  | @ -128,6 +140,7 @@ import { i18n } from '@/i18n'; | |||
| import { getNoteMenu } from '@/scripts/get-note-menu'; | ||||
| import { useNoteCapture } from '@/scripts/use-note-capture'; | ||||
| import { deepClone } from '@/scripts/clone'; | ||||
| import { useTooltip } from '@/scripts/use-tooltip'; | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
| 	note: misskey.entities.Note; | ||||
|  | @ -158,7 +171,7 @@ const isRenote = ( | |||
| 
 | ||||
| const el = shallowRef<HTMLElement>(); | ||||
| const menuButton = shallowRef<HTMLElement>(); | ||||
| const renoteButton = shallowRef<InstanceType<typeof MkRenoteButton>>(); | ||||
| const renoteButton = shallowRef<HTMLElement>(); | ||||
| const renoteTime = shallowRef<HTMLElement>(); | ||||
| const reactButton = shallowRef<HTMLElement>(); | ||||
| let appearNote = $computed(() => isRenote ? note.renote as misskey.entities.Note : note); | ||||
|  | @ -175,6 +188,7 @@ const translation = ref(null); | |||
| const translating = ref(false); | ||||
| const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : null; | ||||
| const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.user.instance); | ||||
| const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id); | ||||
| 
 | ||||
| const keymap = { | ||||
| 	'r': () => reply(true), | ||||
|  | @ -193,6 +207,47 @@ useNoteCapture({ | |||
| 	isDeletedRef: isDeleted, | ||||
| }); | ||||
| 
 | ||||
| useTooltip(renoteButton, async (showing) => { | ||||
| 	const renotes = await os.api('notes/renotes', { | ||||
| 		noteId: appearNote.id, | ||||
| 		limit: 11, | ||||
| 	}); | ||||
| 
 | ||||
| 	const users = renotes.map(x => x.user); | ||||
| 
 | ||||
| 	if (users.length < 1) return; | ||||
| 
 | ||||
| 	os.popup(MkUsersTooltip, { | ||||
| 		showing, | ||||
| 		users, | ||||
| 		count: appearNote.renoteCount, | ||||
| 		targetElement: renoteButton.value, | ||||
| 	}, {}, 'closed'); | ||||
| }); | ||||
| 
 | ||||
| function renote(viaKeyboard = false) { | ||||
| 	pleaseLogin(); | ||||
| 	os.popupMenu([{ | ||||
| 		text: i18n.ts.renote, | ||||
| 		icon: 'ti ti-repeat', | ||||
| 		action: () => { | ||||
| 			os.api('notes/create', { | ||||
| 				renoteId: appearNote.id, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}, { | ||||
| 		text: i18n.ts.quote, | ||||
| 		icon: 'ti ti-quote', | ||||
| 		action: () => { | ||||
| 			os.post({ | ||||
| 				renote: appearNote, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], renoteButton.value, { | ||||
| 		viaKeyboard, | ||||
| 	}); | ||||
| } | ||||
| 
 | ||||
| function reply(viaKeyboard = false): void { | ||||
| 	pleaseLogin(); | ||||
| 	os.post({ | ||||
|  |  | |||
|  | @ -85,14 +85,26 @@ | |||
| 					<i class="ti ti-arrow-back-up"></i> | ||||
| 					<p v-if="appearNote.repliesCount > 0" class="count">{{ appearNote.repliesCount }}</p> | ||||
| 				</button> | ||||
| 				<MkRenoteButton ref="renoteButton" class="button" :note="appearNote" :count="appearNote.renoteCount"/> | ||||
| 				<button v-if="appearNote.myReaction == null" ref="reactButton" class="button _button" @click="react()"> | ||||
| 				<button | ||||
| 					v-if="canRenote" | ||||
| 					ref="renoteButton" | ||||
| 					class="button _button" | ||||
| 					@click="renote()" | ||||
| 					@mousedown="renote()" | ||||
| 				> | ||||
| 					<i class="ti ti-repeat"></i> | ||||
| 					<p v-if="appearNote.renoteCount > 0" class="count">{{ appearNote.renoteCount }}</p> | ||||
| 				</button> | ||||
| 				<button v-else class="button _button" disabled> | ||||
| 					<i class="ti ti-ban"></i> | ||||
| 				</button> | ||||
| 				<button v-if="appearNote.myReaction == null" ref="reactButton" class="button _button" @click="react()" @mousedown="react()"> | ||||
| 					<i class="ti ti-plus"></i> | ||||
| 				</button> | ||||
| 				<button v-if="appearNote.myReaction != null" ref="reactButton" class="button _button reacted" @click="undoReact(appearNote)"> | ||||
| 					<i class="ti ti-minus"></i> | ||||
| 				</button> | ||||
| 				<button ref="menuButton" class="button _button" @click="menu()"> | ||||
| 				<button ref="menuButton" class="button _button" @click="menu()" @mousedown="menu()"> | ||||
| 					<i class="ti ti-dots"></i> | ||||
| 				</button> | ||||
| 			</footer> | ||||
|  | @ -121,7 +133,7 @@ import MkReactionsViewer from '@/components/MkReactionsViewer.vue'; | |||
| import MkMediaList from '@/components/MkMediaList.vue'; | ||||
| import MkCwButton from '@/components/MkCwButton.vue'; | ||||
| import MkPoll from '@/components/MkPoll.vue'; | ||||
| import MkRenoteButton from '@/components/MkRenoteButton.vue'; | ||||
| import MkUsersTooltip from '@/components/MkUsersTooltip.vue'; | ||||
| import MkUrlPreview from '@/components/MkUrlPreview.vue'; | ||||
| import MkInstanceTicker from '@/components/MkInstanceTicker.vue'; | ||||
| import MkVisibility from '@/components/MkVisibility.vue'; | ||||
|  | @ -138,6 +150,7 @@ import { i18n } from '@/i18n'; | |||
| import { getNoteMenu } from '@/scripts/get-note-menu'; | ||||
| import { useNoteCapture } from '@/scripts/use-note-capture'; | ||||
| import { deepClone } from '@/scripts/clone'; | ||||
| import { useTooltip } from '@/scripts/use-tooltip'; | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
| 	note: misskey.entities.Note; | ||||
|  | @ -168,7 +181,7 @@ const isRenote = ( | |||
| 
 | ||||
| const el = shallowRef<HTMLElement>(); | ||||
| const menuButton = shallowRef<HTMLElement>(); | ||||
| const renoteButton = shallowRef<InstanceType<typeof MkRenoteButton>>(); | ||||
| const renoteButton = shallowRef<HTMLElement>(); | ||||
| const renoteTime = shallowRef<HTMLElement>(); | ||||
| const reactButton = shallowRef<HTMLElement>(); | ||||
| let appearNote = $computed(() => isRenote ? note.renote as misskey.entities.Note : note); | ||||
|  | @ -182,6 +195,7 @@ const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : n | |||
| const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.user.instance); | ||||
| const conversation = ref<misskey.entities.Note[]>([]); | ||||
| const replies = ref<misskey.entities.Note[]>([]); | ||||
| const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id); | ||||
| 
 | ||||
| const keymap = { | ||||
| 	'r': () => reply(true), | ||||
|  | @ -198,6 +212,47 @@ useNoteCapture({ | |||
| 	isDeletedRef: isDeleted, | ||||
| }); | ||||
| 
 | ||||
| useTooltip(renoteButton, async (showing) => { | ||||
| 	const renotes = await os.api('notes/renotes', { | ||||
| 		noteId: appearNote.id, | ||||
| 		limit: 11, | ||||
| 	}); | ||||
| 
 | ||||
| 	const users = renotes.map(x => x.user); | ||||
| 
 | ||||
| 	if (users.length < 1) return; | ||||
| 
 | ||||
| 	os.popup(MkUsersTooltip, { | ||||
| 		showing, | ||||
| 		users, | ||||
| 		count: appearNote.renoteCount, | ||||
| 		targetElement: renoteButton.value, | ||||
| 	}, {}, 'closed'); | ||||
| }); | ||||
| 
 | ||||
| function renote(viaKeyboard = false) { | ||||
| 	pleaseLogin(); | ||||
| 	os.popupMenu([{ | ||||
| 		text: i18n.ts.renote, | ||||
| 		icon: 'ti ti-repeat', | ||||
| 		action: () => { | ||||
| 			os.api('notes/create', { | ||||
| 				renoteId: appearNote.id, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}, { | ||||
| 		text: i18n.ts.quote, | ||||
| 		icon: 'ti ti-quote', | ||||
| 		action: () => { | ||||
| 			os.post({ | ||||
| 				renote: appearNote, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], renoteButton.value, { | ||||
| 		viaKeyboard, | ||||
| 	}); | ||||
| } | ||||
| 
 | ||||
| function reply(viaKeyboard = false): void { | ||||
| 	pleaseLogin(); | ||||
| 	os.post({ | ||||
|  |  | |||
|  | @ -1,99 +0,0 @@ | |||
| <template> | ||||
| <button | ||||
| 	v-if="canRenote" | ||||
| 	ref="buttonRef" | ||||
| 	class="eddddedb _button canRenote" | ||||
| 	@click="renote()" | ||||
| > | ||||
| 	<i class="ti ti-repeat"></i> | ||||
| 	<p v-if="count > 0" class="count">{{ count }}</p> | ||||
| </button> | ||||
| <button v-else class="eddddedb _button"> | ||||
| 	<i class="ti ti-ban"></i> | ||||
| </button> | ||||
| </template> | ||||
| 
 | ||||
| <script lang="ts" setup> | ||||
| import { computed, ref, shallowRef } from 'vue'; | ||||
| import * as misskey from 'misskey-js'; | ||||
| import XDetails from '@/components/MkUsersTooltip.vue'; | ||||
| import { pleaseLogin } from '@/scripts/please-login'; | ||||
| import * as os from '@/os'; | ||||
| import { $i } from '@/account'; | ||||
| import { useTooltip } from '@/scripts/use-tooltip'; | ||||
| import { i18n } from '@/i18n'; | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
| 	note: misskey.entities.Note; | ||||
| 	count: number; | ||||
| }>(); | ||||
| 
 | ||||
| const buttonRef = shallowRef<HTMLElement>(); | ||||
| 
 | ||||
| const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id); | ||||
| 
 | ||||
| useTooltip(buttonRef, async (showing) => { | ||||
| 	const renotes = await os.api('notes/renotes', { | ||||
| 		noteId: props.note.id, | ||||
| 		limit: 11, | ||||
| 	}); | ||||
| 
 | ||||
| 	const users = renotes.map(x => x.user); | ||||
| 
 | ||||
| 	if (users.length < 1) return; | ||||
| 
 | ||||
| 	os.popup(XDetails, { | ||||
| 		showing, | ||||
| 		users, | ||||
| 		count: props.count, | ||||
| 		targetElement: buttonRef.value, | ||||
| 	}, {}, 'closed'); | ||||
| }); | ||||
| 
 | ||||
| const renote = (viaKeyboard = false) => { | ||||
| 	pleaseLogin(); | ||||
| 	os.popupMenu([{ | ||||
| 		text: i18n.ts.renote, | ||||
| 		icon: 'ti ti-repeat', | ||||
| 		action: () => { | ||||
| 			os.api('notes/create', { | ||||
| 				renoteId: props.note.id, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}, { | ||||
| 		text: i18n.ts.quote, | ||||
| 		icon: 'ti ti-quote', | ||||
| 		action: () => { | ||||
| 			os.post({ | ||||
| 				renote: props.note, | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], buttonRef.value, { | ||||
| 		viaKeyboard, | ||||
| 	}); | ||||
| }; | ||||
| </script> | ||||
| 
 | ||||
| <style lang="scss" scoped> | ||||
| .eddddedb { | ||||
| 	display: inline-block; | ||||
| 	height: 32px; | ||||
| 	margin: 2px; | ||||
| 	padding: 0 6px; | ||||
| 	border-radius: 4px; | ||||
| 
 | ||||
| 	&:not(.canRenote) { | ||||
| 		cursor: default; | ||||
| 	} | ||||
| 
 | ||||
| 	&.renoted { | ||||
| 		background: var(--accent); | ||||
| 	} | ||||
| 
 | ||||
| 	> .count { | ||||
| 		display: inline; | ||||
| 		margin-left: 8px; | ||||
| 		opacity: 0.7; | ||||
| 	} | ||||
| } | ||||
| </style> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue