Skip to content

Commit 6b159e8

Browse files
authored
Merge pull request #17 from sweshelo/feat/reaction-user-icon-from-resolove
Feat/reaction user icon from resolove
2 parents f8b8dc8 + 7bc65c1 commit 6b159e8

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

packages/frontend/src/components/MkReactionsViewer.reaction.vue

+44-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ SPDX-License-Identifier: AGPL-3.0-only
1313
@contextmenu.prevent.stop="menu"
1414
>
1515
<MkReactionIcon :class="defaultStore.state.limitWidthOfReaction ? $style.limitWidth : ''" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substring(1, reaction.length - 1)]"/>
16-
<span :class="$style.count">{{ count }}</span>
16+
<span :class="$style.count">
17+
</span>
18+
<div v-for="u in users" :key="u.id" :class="$style.avatars" style="height: 42px; width: auto">
19+
<MkAvatar :class="$style.avatar" :user="u"/>
20+
</div>
1721
</button>
1822
</template>
1923

2024
<script lang="ts" setup>
21-
import { computed, inject, onMounted, shallowRef, watch } from 'vue';
25+
import { computed, inject, onMounted, shallowRef, watch, ref } from 'vue';
2226
import * as Misskey from 'misskey-js';
2327
import MkCustomEmojiDetailedDialog from './MkCustomEmojiDetailedDialog.vue';
2428
import XDetails from '@/components/MkReactionsViewer.details.vue';
@@ -60,6 +64,15 @@ const canToggle = computed(() => {
6064
});
6165
const canGetInfo = computed(() => !props.reaction.match(/@\w/) && props.reaction.includes(':'));
6266

67+
// const reactions = await misskeyApiGet('notes/reactions', {
68+
// noteId: props.note.id,
69+
// type: props.reaction,
70+
// limit: 10,
71+
// _cacheKey_: props.count,
72+
// });
73+
74+
const users = ref([]);
75+
6376
async function toggleReaction() {
6477
if (!canToggle.value) return;
6578

@@ -124,10 +137,28 @@ function anime() {
124137
}
125138

126139
watch(() => props.count, (newCount, oldCount) => {
140+
console.log('count changed', oldCount, newCount);
141+
misskeyApiGet('notes/reactions', {
142+
noteId: props.note.id,
143+
type: props.reaction,
144+
limit: 10,
145+
_cacheKey_: newCount,
146+
}).then((reactions) => {
147+
users.value = reactions.map(x => x.user);
148+
});
149+
127150
if (oldCount < newCount) anime();
128151
});
129152

130153
onMounted(() => {
154+
misskeyApiGet('notes/reactions', {
155+
noteId: props.note.id,
156+
type: props.reaction,
157+
limit: 10,
158+
}).then((reactions) => {
159+
users.value = reactions.map(x => x.user);
160+
});
161+
131162
if (!props.isInitial) anime();
132163
});
133164

@@ -154,6 +185,17 @@ if (!mock) {
154185
</script>
155186

156187
<style lang="scss" module>
188+
.avatars {
189+
display: flex;
190+
align-items: center;
191+
}
192+
193+
.avatar {
194+
height: 14px;
195+
width: 14px;
196+
margin-left: 2px;
197+
}
198+
157199
.root {
158200
display: inline-flex;
159201
height: 42px;

0 commit comments

Comments
 (0)