Skip to content
Snippets Groups Projects
Unverified Commit fa75b40d authored by MeiMei's avatar MeiMei Committed by GitHub
Browse files

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

parent f32d8b70
No related branches found
No related tags found
No related merge requests found
<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({ ...@@ -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({ ...@@ -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,19 +142,23 @@ export default Vue.extend({ ...@@ -144,19 +142,23 @@ export default Vue.extend({
padding: 0 6px; padding: 0 6px;
border-radius: 4px; border-radius: 4px;
&.reacted { &.canToggle {
background: var(--accent); background: rgba(0, 0, 0, 0.05);
> span { &:hover {
color: #fff; background: rgba(0, 0, 0, 0.1);
} }
} }
&:not(.reacted) { &:not(.canToggle) {
background: rgba(0, 0, 0, 0.05); cursor: default;
}
&:hover { &.reacted {
background: rgba(0, 0, 0, 0.1); background: var(--accent);
> span {
color: #fff;
} }
} }
......
...@@ -70,7 +70,7 @@ export async function toDbReaction(reaction?: string | null, reacterHost?: strin ...@@ -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({
......
...@@ -72,13 +72,13 @@ export default async (user: User, note: Note, reaction?: string) => { ...@@ -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
}); });
......
...@@ -7,6 +7,7 @@ import { IdentifiableError } from '../../../misc/identifiable-error'; ...@@ -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) => { ...@@ -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
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment