summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-09-03 07:25:02 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-09-03 07:25:02 +0900
commitd36b129369ccb67dcba27b2cd3544fdf270abef7 (patch)
tree2def2685ddce8bbeca8dfaeaecb38d9ff97f2592
parentFetch more reactins (diff)
downloadsharkey-d36b129369ccb67dcba27b2cd3544fdf270abef7.tar.gz
sharkey-d36b129369ccb67dcba27b2cd3544fdf270abef7.tar.bz2
sharkey-d36b129369ccb67dcba27b2cd3544fdf270abef7.zip
Improve reaction tooltip
-rw-r--r--src/client/app/common/views/components/reactions-viewer.details.vue6
-rw-r--r--src/client/app/common/views/components/reactions-viewer.reaction.vue6
-rw-r--r--src/server/api/endpoints/notes/reactions.ts12
3 files changed, 20 insertions, 4 deletions
diff --git a/src/client/app/common/views/components/reactions-viewer.details.vue b/src/client/app/common/views/components/reactions-viewer.details.vue
index efe7eb39ba..35c648278d 100644
--- a/src/client/app/common/views/components/reactions-viewer.details.vue
+++ b/src/client/app/common/views/components/reactions-viewer.details.vue
@@ -12,7 +12,7 @@
</i18n>
<i18n path="many-users" v-if="10 < users.length">
<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" />
</i18n>
</div>
@@ -34,6 +34,10 @@ export default Vue.extend({
type: Array,
required: true,
},
+ count: {
+ type: Number,
+ required: true,
+ },
source: {
required: true,
}
diff --git a/src/client/app/common/views/components/reactions-viewer.reaction.vue b/src/client/app/common/views/components/reactions-viewer.reaction.vue
index c06430e5eb..dade012c29 100644
--- a/src/client/app/common/views/components/reactions-viewer.reaction.vue
+++ b/src/client/app/common/views/components/reactions-viewer.reaction.vue
@@ -102,9 +102,10 @@ export default Vue.extend({
if (this.$root.isMobile) return;
this.$root.api('notes/reactions', {
noteId: this.note.id,
- limit: 30
+ type: this.reaction,
+ limit: 11
}).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())
.map(x => x.user);
@@ -113,6 +114,7 @@ export default Vue.extend({
this.details = this.$root.new(XDetails, {
reaction: this.reaction,
users,
+ count: this.count,
source: this.$refs.reaction
});
});
diff --git a/src/server/api/endpoints/notes/reactions.ts b/src/server/api/endpoints/notes/reactions.ts
index 7bea24d316..742489c0cd 100644
--- a/src/server/api/endpoints/notes/reactions.ts
+++ b/src/server/api/endpoints/notes/reactions.ts
@@ -4,6 +4,8 @@ import define from '../../define';
import { getNote } from '../../common/getters';
import { ApiError } from '../../error';
import { NoteReactions } from '../../../../models';
+import { DeepPartial } from 'typeorm';
+import { NoteReaction } from '../../../../models/entities/note-reaction';
export const meta = {
desc: {
@@ -24,6 +26,10 @@ export const meta = {
}
},
+ type: {
+ validator: $.optional.nullable.str,
+ },
+
limit: {
validator: $.optional.num.range(1, 100),
default: 10
@@ -70,7 +76,11 @@ export default define(meta, async (ps, user) => {
const query = {
noteId: note.id
- };
+ } as DeepPartial<NoteReaction>;
+
+ if (ps.type) {
+ query.reaction = ps.type;
+ }
const reactions = await NoteReactions.find({
where: query,