リアクションの修正 (#6260)

This commit is contained in:
MeiMei 2020-04-16 00:47:17 +09:00 committed by GitHub
parent f32d8b7069
commit fa75b40dfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 18 deletions

View file

@ -1,7 +1,7 @@
<template> <template>
<button <button
class="hkzvhatu _button" class="hkzvhatu _button"
:class="{ reacted: note.myReaction == reaction }" :class="{ reacted: note.myReaction == reaction, canToggle }"
@click="toggleReaction(reaction)" @click="toggleReaction(reaction)"
v-if="count > 0" v-if="count > 0"
@mouseover="onMouseover" @mouseover="onMouseover"
@ -40,11 +40,6 @@ export default Vue.extend({
type: Object, type: Object,
required: true, required: true,
}, },
canToggle: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
@ -57,6 +52,9 @@ export default Vue.extend({
isMe(): boolean { isMe(): boolean {
return this.$store.getters.isSignedIn && this.$store.state.i.id === this.note.userId; return this.$store.getters.isSignedIn && this.$store.state.i.id === this.note.userId;
}, },
canToggle(): boolean {
return !this.reaction.match(/@\w/);
},
}, },
mounted() { mounted() {
if (!this.isInitial) this.anime(); if (!this.isInitial) this.anime();
@ -144,6 +142,18 @@ export default Vue.extend({
padding: 0 6px; padding: 0 6px;
border-radius: 4px; border-radius: 4px;
&.canToggle {
background: rgba(0, 0, 0, 0.05);
&:hover {
background: rgba(0, 0, 0, 0.1);
}
}
&:not(.canToggle) {
cursor: default;
}
&.reacted { &.reacted {
background: var(--accent); background: var(--accent);
@ -152,14 +162,6 @@ export default Vue.extend({
} }
} }
&:not(.reacted) {
background: rgba(0, 0, 0, 0.05);
&:hover {
background: rgba(0, 0, 0, 0.1);
}
}
> span { > span {
font-size: 0.9em; font-size: 0.9em;
line-height: 32px; line-height: 32px;

View file

@ -70,7 +70,7 @@ export async function toDbReaction(reaction?: string | null, reacterHost?: strin
return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, ''); return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, '');
} }
const custom = reaction.match(/^:([\w+-]+):$/); const custom = reaction.match(/^:([\w+-]+)(?:@\.)?:$/);
if (custom) { if (custom) {
const name = custom[1]; const name = custom[1];
const emoji = await Emojis.findOne({ const emoji = await Emojis.findOne({

View file

@ -72,13 +72,13 @@ export default async (user: User, note: Note, reaction?: string) => {
if (emoji) { if (emoji) {
emoji = { emoji = {
name: emoji.host ? `${emoji.name}@${emoji.host}` : `${emoji.name}`, name: emoji.host ? `${emoji.name}@${emoji.host}` : `${emoji.name}@.`,
url: emoji.url url: emoji.url
} as any; } as any;
} }
publishNoteStream(note.id, 'reacted', { publishNoteStream(note.id, 'reacted', {
reaction: reaction, reaction: decodedReaction.reaction,
emoji: emoji, emoji: emoji,
userId: user.id userId: user.id
}); });

View file

@ -7,6 +7,7 @@ import { IdentifiableError } from '../../../misc/identifiable-error';
import { User, IRemoteUser } from '../../../models/entities/user'; import { User, IRemoteUser } from '../../../models/entities/user';
import { Note } from '../../../models/entities/note'; import { Note } from '../../../models/entities/note';
import { NoteReactions, Users, Notes } from '../../../models'; import { NoteReactions, Users, Notes } from '../../../models';
import { decodeReaction } from '../../../misc/reaction-lib';
export default async (user: User, note: Note) => { export default async (user: User, note: Note) => {
// if already unreacted // if already unreacted
@ -38,7 +39,7 @@ export default async (user: User, note: Note) => {
Notes.decrement({ id: note.id }, 'score', 1); Notes.decrement({ id: note.id }, 'score', 1);
publishNoteStream(note.id, 'unreacted', { publishNoteStream(note.id, 'unreacted', {
reaction: exist.reaction, reaction: decodeReaction(exist.reaction).reaction,
userId: user.id userId: user.id
}); });