リアクションの修正 (#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>
<button
class="hkzvhatu _button"
:class="{ reacted: note.myReaction == reaction }"
:class="{ reacted: note.myReaction == reaction, canToggle }"
@click="toggleReaction(reaction)"
v-if="count > 0"
@mouseover="onMouseover"
@ -40,11 +40,6 @@ export default Vue.extend({
type: Object,
required: true,
},
canToggle: {
type: Boolean,
required: false,
default: true,
},
},
data() {
return {
@ -57,6 +52,9 @@ export default Vue.extend({
isMe(): boolean {
return this.$store.getters.isSignedIn && this.$store.state.i.id === this.note.userId;
},
canToggle(): boolean {
return !this.reaction.match(/@\w/);
},
},
mounted() {
if (!this.isInitial) this.anime();
@ -144,6 +142,18 @@ export default Vue.extend({
padding: 0 6px;
border-radius: 4px;
&.canToggle {
background: rgba(0, 0, 0, 0.05);
&:hover {
background: rgba(0, 0, 0, 0.1);
}
}
&:not(.canToggle) {
cursor: default;
}
&.reacted {
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 {
font-size: 0.9em;
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, '');
}
const custom = reaction.match(/^:([\w+-]+):$/);
const custom = reaction.match(/^:([\w+-]+)(?:@\.)?:$/);
if (custom) {
const name = custom[1];
const emoji = await Emojis.findOne({

View file

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

View file

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