mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-02 17:55:52 +02:00
enhance(frontend): リアクションビューワーで使用可能なリアクションを優先して表示するオプション (#16149)
* enhance(frontend): リアクションビューワーで使用可能なリアクションを優先して表示するオプション * Update Changelog * tweak * fix * enhance: リアクティブじゃなくする --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,10 @@ import * as Misskey from 'misskey-js';
|
||||
import { inject, watch, ref } from 'vue';
|
||||
import { TransitionGroup } from 'vue';
|
||||
import XReaction from '@/components/MkReactionsViewer.reaction.vue';
|
||||
import { $i } from '@/i.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import { customEmojisMap } from '@/custom-emojis.js';
|
||||
import { isSupportedEmoji } from '@@/js/emojilist.js';
|
||||
import { DI } from '@/di.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -70,6 +73,12 @@ function onMockToggleReaction(emoji: string, count: number) {
|
||||
emit('mockUpdateMyReaction', emoji, (count - _reactions.value[i][1]));
|
||||
}
|
||||
|
||||
function canReact(reaction: string) {
|
||||
if (!$i) return false;
|
||||
// TODO: CheckPermissions
|
||||
return !reaction.match(/@\w/) && (customEmojisMap.has(reaction) || isSupportedEmoji(reaction));
|
||||
}
|
||||
|
||||
watch([() => props.reactions, () => props.maxNumber], ([newSource, maxNumber]) => {
|
||||
let newReactions: [string, number][] = [];
|
||||
hasMoreReactions.value = Object.keys(newSource).length > maxNumber;
|
||||
@@ -86,7 +95,15 @@ watch([() => props.reactions, () => props.maxNumber], ([newSource, maxNumber]) =
|
||||
newReactions = [
|
||||
...newReactions,
|
||||
...Object.entries(newSource)
|
||||
.sort(([, a], [, b]) => b - a)
|
||||
.sort(([emojiA, countA], [emojiB, countB]) => {
|
||||
if (prefer.s.showAvailableReactionsFirstInNote) {
|
||||
if (!canReact(emojiA) && canReact(emojiB)) return 1;
|
||||
if (canReact(emojiA) && !canReact(emojiB)) return -1;
|
||||
return countB - countA;
|
||||
} else {
|
||||
return countB - countA;
|
||||
}
|
||||
})
|
||||
.filter(([y], i) => i < maxNumber && !newReactionsNames.includes(y)),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user