forked from FoundKeyGang/FoundKey
Improve reaction tooltip
This commit is contained in:
parent
f36d88246a
commit
d36b129369
3 changed files with 20 additions and 4 deletions
|
@ -12,7 +12,7 @@
|
||||||
</i18n>
|
</i18n>
|
||||||
<i18n path="many-users" v-if="10 < users.length">
|
<i18n path="many-users" v-if="10 < users.length">
|
||||||
<span slot="users">{{ users.slice(0, 10).join(', ') }}</span>
|
<span slot="users">{{ users.slice(0, 10).join(', ') }}</span>
|
||||||
<span slot="ommited">{{ users.length - 10 }}</span>
|
<span slot="ommited">{{ count - 10 }}</span>
|
||||||
<mk-reaction-icon slot="reaction" :reaction="reaction" ref="icon" />
|
<mk-reaction-icon slot="reaction" :reaction="reaction" ref="icon" />
|
||||||
</i18n>
|
</i18n>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,6 +34,10 @@ export default Vue.extend({
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
count: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
source: {
|
source: {
|
||||||
required: true,
|
required: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,10 @@ export default Vue.extend({
|
||||||
if (this.$root.isMobile) return;
|
if (this.$root.isMobile) return;
|
||||||
this.$root.api('notes/reactions', {
|
this.$root.api('notes/reactions', {
|
||||||
noteId: this.note.id,
|
noteId: this.note.id,
|
||||||
limit: 30
|
type: this.reaction,
|
||||||
|
limit: 11
|
||||||
}).then((reactions: any[]) => {
|
}).then((reactions: any[]) => {
|
||||||
const users = reactions.filter(x => x.type === this.reaction)
|
const users = reactions
|
||||||
.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())
|
.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())
|
||||||
.map(x => x.user);
|
.map(x => x.user);
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ export default Vue.extend({
|
||||||
this.details = this.$root.new(XDetails, {
|
this.details = this.$root.new(XDetails, {
|
||||||
reaction: this.reaction,
|
reaction: this.reaction,
|
||||||
users,
|
users,
|
||||||
|
count: this.count,
|
||||||
source: this.$refs.reaction
|
source: this.$refs.reaction
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,8 @@ import define from '../../define';
|
||||||
import { getNote } from '../../common/getters';
|
import { getNote } from '../../common/getters';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { NoteReactions } from '../../../../models';
|
import { NoteReactions } from '../../../../models';
|
||||||
|
import { DeepPartial } from 'typeorm';
|
||||||
|
import { NoteReaction } from '../../../../models/entities/note-reaction';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -24,6 +26,10 @@ export const meta = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
type: {
|
||||||
|
validator: $.optional.nullable.str,
|
||||||
|
},
|
||||||
|
|
||||||
limit: {
|
limit: {
|
||||||
validator: $.optional.num.range(1, 100),
|
validator: $.optional.num.range(1, 100),
|
||||||
default: 10
|
default: 10
|
||||||
|
@ -70,7 +76,11 @@ export default define(meta, async (ps, user) => {
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
noteId: note.id
|
noteId: note.id
|
||||||
};
|
} as DeepPartial<NoteReaction>;
|
||||||
|
|
||||||
|
if (ps.type) {
|
||||||
|
query.reaction = ps.type;
|
||||||
|
}
|
||||||
|
|
||||||
const reactions = await NoteReactions.find({
|
const reactions = await NoteReactions.find({
|
||||||
where: query,
|
where: query,
|
||||||
|
|
Loading…
Reference in a new issue