reactiveやめる

This commit is contained in:
tai-cha 2025-05-12 08:58:39 +09:00
parent c3c11d25ce
commit 442742c371
No known key found for this signature in database
GPG Key ID: 1D5EE39F870DC283
5 changed files with 17 additions and 9 deletions

View File

@ -147,6 +147,7 @@ async function menu(ev) {
os.confirm({
type: 'question',
title: i18n.tsx.unmuteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) return;
unmuteEmoji(props.reaction);
@ -161,6 +162,7 @@ async function menu(ev) {
os.confirm({
type: 'question',
title: i18n.tsx.muteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) return;
muteEmoji(props.reaction);

View File

@ -199,6 +199,7 @@ function mute() {
os.confirm({
type: 'question',
title: i18n.tsx.muteX({ x: titleEmojiName }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) {
return;
@ -214,6 +215,7 @@ function unmute() {
os.confirm({
type: 'question',
title: i18n.tsx.unmuteX({ x: titleEmojiName }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) {
return;

View File

@ -47,6 +47,7 @@ function mute() {
os.confirm({
type: 'question',
title: i18n.tsx.muteX({ x: props.emoji }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) {
return;
@ -59,6 +60,7 @@ function unmute() {
os.confirm({
type: 'question',
title: i18n.tsx.unmuteX({ x: props.emoji }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) {
return;

View File

@ -72,6 +72,7 @@ function unmute(emoji: string) {
os.confirm({
type: 'question',
title: i18n.tsx.unmuteX({ x: emoji }),
text: i18n.ts.reloadToApplySetting,
}).then(({ canceled }) => {
if (canceled) {
return;

View File

@ -11,10 +11,12 @@ export function makeEmojiMuteKey(props: { name: string; host?: string | null })
return props.name.startsWith(':') ? props.name : `:${props.name}${props.host ? `@${props.host}` : ''}:`;
}
// custom絵文字の名前部分を取り出す
export function extractCustomEmojiName (name:string) {
return (name[0] === ':' ? name.substring(1, name.length - 1) : name).replace('@.', '').split('@')[0];
}
// custom絵文字のホスト部分を取り出す
export function extractCustomEmojiHost (name:string) {
// nameは:emojiName@host:の形式
// 取り出したい部分はhostなので、@以降を取り出す
@ -29,26 +31,25 @@ export function extractCustomEmojiHost (name:string) {
return host;
}
export function mute(emoji: string) {
export async function mute(emoji: string) {
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
const emojiMuteKey = isCustomEmoji ?
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
emoji;
const mutedEmojis = prefer.r.mutingEmojis.value;
const mutedEmojis = prefer.s.mutingEmojis;
if (!mutedEmojis.includes(emoji)) {
prefer.commit('mutingEmojis', [...mutedEmojis, emojiMuteKey]);
return prefer.commit('mutingEmojis', [...mutedEmojis, emojiMuteKey]);
}
throw new Error('Emoji is already muted');
}
export function unmute(emoji:string) {
export async function unmute(emoji:string) {
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
const emojiMuteKey = isCustomEmoji ?
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
emoji;
const mutedEmojis = prefer.r.mutingEmojis.value;
console.log('unmute', emoji, emojiMuteKey);
console.log('mutedEmojis', mutedEmojis);
prefer.commit('mutingEmojis', mutedEmojis.filter((e) => e !== emojiMuteKey));
const mutedEmojis = prefer.s.mutingEmojis;
return prefer.commit('mutingEmojis', mutedEmojis.filter((e) => e !== emojiMuteKey));
}
export function checkMuted(emoji: string) {
@ -56,5 +57,5 @@ export function checkMuted(emoji: string) {
const emojiMuteKey = isCustomEmoji ?
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
emoji;
return computed(() => prefer.r.mutingEmojis.value.includes(emojiMuteKey));
return computed(() => prefer.s.mutingEmojis.includes(emojiMuteKey));
}