Skip to content

Commit

Permalink
Merge pull request #18 from serafuku/serafuku-dev
Browse files Browse the repository at this point in the history
2024.10.0-serafuku.2
  • Loading branch information
yunochi authored Oct 14, 2024
2 parents 866042e + f308404 commit 1c3c0c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "2024.10.0+serafuku.1",
"version": "2024.10.0+serafuku.2",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
14 changes: 8 additions & 6 deletions packages/frontend/src/components/MkReactionsViewer.reaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ const emit = defineEmits<{
const buttonEl = shallowRef<HTMLElement>();

const emojiName = computed(() => props.reaction.replace(/:/g, '').replace(/@\./, ''));
const emoji = computed(() => customEmojisMap.get(emojiName.value) ?? getUnicodeEmoji(props.reaction));
const emojiNameWithoutHost = computed(() => emojiName.value.replace(/@[\w.]+/, ''));
const localEmoji = computed(() => props.reaction.includes(':') ? customEmojisMap.get(emojiNameWithoutHost.value) : getUnicodeEmoji(props.reaction));

const canToggle = computed(() => {
return !props.reaction.match(/@\w/) && $i && emoji.value && checkReactionPermissions($i, props.note, emoji.value);
return $i && localEmoji.value && checkReactionPermissions($i, props.note, localEmoji.value);
});
const canGetInfo = computed(() => !props.reaction.match(/@\w/) && props.reaction.includes(':'));
const canGetInfo = computed(() => props.reaction.includes(':') && localEmoji.value);

async function toggleReaction() {
if (!canToggle.value) return;

const oldReaction = props.note.myReaction;
const selected = props.reaction.includes(':') ? `:${emojiNameWithoutHost.value}:` : props.reaction;
if (oldReaction) {
const confirm = await os.confirm({
type: 'warning',
Expand All @@ -85,7 +87,7 @@ async function toggleReaction() {
if (oldReaction !== props.reaction) {
misskeyApi('notes/reactions/create', {
noteId: props.note.id,
reaction: props.reaction,
reaction: selected,
});
}
});
Expand All @@ -99,7 +101,7 @@ async function toggleReaction() {

misskeyApi('notes/reactions/create', {
noteId: props.note.id,
reaction: props.reaction,
reaction: selected,
});
if (props.note.text && props.note.text.length > 100 && (Date.now() - new Date(props.note.createdAt).getTime() < 1000 * 3)) {
claimAchievement('reactWithoutRead');
Expand All @@ -116,7 +118,7 @@ async function menu(ev) {
action: async () => {
const { dispose } = os.popup(MkCustomEmojiDetailedDialog, {
emoji: await misskeyApiGet('emoji', {
name: props.reaction.replace(/:/g, '').replace(/@\./, ''),
name: emojiNameWithoutHost.value,
}),
}, {
closed: () => dispose(),
Expand Down
12 changes: 7 additions & 5 deletions packages/frontend/src/components/global/MkCustomEmoji.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const props = defineProps<{
const react = inject<((name: string) => void) | null>('react', null);

const customEmojiName = computed(() => (props.name[0] === ':' ? props.name.substring(1, props.name.length - 1) : props.name).replace('@.', ''));
const customEmojiNameWithoutHost = computed(() => customEmojiName.value.replace(/@[\w.]+/, ''));
const isLocal = computed(() => !props.host && (customEmojiName.value.endsWith('@.') || !customEmojiName.value.includes('@')));
const localEmoji = computed(() => customEmojisMap.get(customEmojiNameWithoutHost.value)); // 같은 이름을 가진 로컬 에모지

const rawUrl = computed(() => {
if (props.url) {
Expand Down Expand Up @@ -85,17 +87,17 @@ const alt = computed(() => `:${customEmojiName.value}:`);
const errored = ref(url.value == null);

function onClick(ev: MouseEvent) {
if (props.menu) {
if (props.menu && localEmoji.value) {
const menuItems: MenuItem[] = [];

menuItems.push({
type: 'label',
text: `:${props.name}:`,
text: `:${customEmojiNameWithoutHost.value}:`,
}, {
text: i18n.ts.copy,
icon: 'ti ti-copy',
action: () => {
copyToClipboard(`:${props.name}:`);
copyToClipboard(`:${customEmojiNameWithoutHost.value}:`);
os.success();
},
});
Expand All @@ -105,7 +107,7 @@ function onClick(ev: MouseEvent) {
text: i18n.ts.doReaction,
icon: 'ti ti-plus',
action: () => {
react(`:${props.name}:`);
react(`:${customEmojiNameWithoutHost.value}:`);
sound.playMisskeySfx('reaction');
},
});
Expand All @@ -117,7 +119,7 @@ function onClick(ev: MouseEvent) {
action: async () => {
const { dispose } = os.popup(MkCustomEmojiDetailedDialog, {
emoji: await misskeyApiGet('emoji', {
name: customEmojiName.value,
name: customEmojiNameWithoutHost.value,
}),
}, {
closed: () => dispose(),
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/components/global/MkMfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
url: props.emojiUrls && props.emojiUrls[token.props.name],
normal: props.plain,
host: props.author.host,
menu: props.enableEmojiMenu,
menuReaction: props.enableEmojiMenuReaction,
useOriginalSize: scale >= 2.5,
})];
}
Expand Down

0 comments on commit 1c3c0c5

Please sign in to comment.