parent
25afca99b8
commit
1f470372ed
|
@ -168,7 +168,6 @@ async function menu(ev) {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.unmuteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
|
title: i18n.tsx.unmuteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
unmuteEmoji(props.reaction);
|
unmuteEmoji(props.reaction);
|
||||||
|
@ -183,7 +182,6 @@ async function menu(ev) {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.muteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
|
title: i18n.tsx.muteX({ x: isLocalCustomEmoji ? `:${emojiName.value}:` : props.reaction }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
muteEmoji(props.reaction);
|
muteEmoji(props.reaction);
|
||||||
|
|
|
@ -199,7 +199,6 @@ function mute() {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.muteX({ x: titleEmojiName }),
|
title: i18n.tsx.muteX({ x: titleEmojiName }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
return;
|
return;
|
||||||
|
@ -215,7 +214,6 @@ function unmute() {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.unmuteX({ x: titleEmojiName }),
|
title: i18n.tsx.unmuteX({ x: titleEmojiName }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -47,7 +47,6 @@ function mute() {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.muteX({ x: props.emoji }),
|
title: i18n.tsx.muteX({ x: props.emoji }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
return;
|
return;
|
||||||
|
@ -60,7 +59,6 @@ function unmute() {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.unmuteX({ x: props.emoji }),
|
title: i18n.tsx.unmuteX({ x: props.emoji }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -72,7 +72,6 @@ function unmute(emoji: string) {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
title: i18n.tsx.unmuteX({ x: emoji }),
|
title: i18n.tsx.unmuteX({ x: emoji }),
|
||||||
text: i18n.ts.reloadToApplySetting,
|
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,12 +11,10 @@ export function makeEmojiMuteKey(props: { name: string; host?: string | null })
|
||||||
return props.name.startsWith(':') ? props.name : `:${props.name}${props.host ? `@${props.host}` : ''}:`;
|
return props.name.startsWith(':') ? props.name : `:${props.name}${props.host ? `@${props.host}` : ''}:`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom絵文字の名前部分を取り出す
|
|
||||||
export function extractCustomEmojiName (name:string) {
|
export function extractCustomEmojiName (name:string) {
|
||||||
return (name[0] === ':' ? name.substring(1, name.length - 1) : name).replace('@.', '').split('@')[0];
|
return (name[0] === ':' ? name.substring(1, name.length - 1) : name).replace('@.', '').split('@')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom絵文字のホスト部分を取り出す
|
|
||||||
export function extractCustomEmojiHost (name:string) {
|
export function extractCustomEmojiHost (name:string) {
|
||||||
// nameは:emojiName@host:の形式
|
// nameは:emojiName@host:の形式
|
||||||
// 取り出したい部分はhostなので、@以降を取り出す
|
// 取り出したい部分はhostなので、@以降を取り出す
|
||||||
|
@ -31,25 +29,27 @@ export function extractCustomEmojiHost (name:string) {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mute(emoji: string) {
|
export function mute(emoji: string) {
|
||||||
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
|
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
|
||||||
const emojiMuteKey = isCustomEmoji ?
|
const emojiMuteKey = isCustomEmoji ?
|
||||||
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
||||||
emoji;
|
emoji;
|
||||||
const mutedEmojis = prefer.s.mutingEmojis;
|
const mutedEmojis = prefer.r.mutingEmojis.value;
|
||||||
if (!mutedEmojis.includes(emojiMuteKey)) {
|
if (!mutedEmojis.includes(emojiMuteKey)) {
|
||||||
return prefer.commit('mutingEmojis', [...mutedEmojis, emojiMuteKey]);
|
return prefer.commit('mutingEmojis', [...mutedEmojis, emojiMuteKey]);
|
||||||
}
|
}
|
||||||
throw new Error('Emoji is already muted', { cause: `${emojiMuteKey} is Already Muted` });
|
throw new Error('Emoji is already muted', { cause: `${emojiMuteKey} is Already Muted` });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function unmute(emoji:string) {
|
export function unmute(emoji:string) {
|
||||||
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
|
const isCustomEmoji = emoji.startsWith(':') && emoji.endsWith(':');
|
||||||
const emojiMuteKey = isCustomEmoji ?
|
const emojiMuteKey = isCustomEmoji ?
|
||||||
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
||||||
emoji;
|
emoji;
|
||||||
const mutedEmojis = prefer.s.mutingEmojis;
|
const mutedEmojis = prefer.r.mutingEmojis.value;
|
||||||
return prefer.commit('mutingEmojis', mutedEmojis.filter((e) => e !== emojiMuteKey));
|
console.log('unmute', emoji, emojiMuteKey);
|
||||||
|
console.log('mutedEmojis', mutedEmojis);
|
||||||
|
prefer.commit('mutingEmojis', mutedEmojis.filter((e) => e !== emojiMuteKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkMuted(emoji: string) {
|
export function checkMuted(emoji: string) {
|
||||||
|
@ -57,5 +57,5 @@ export function checkMuted(emoji: string) {
|
||||||
const emojiMuteKey = isCustomEmoji ?
|
const emojiMuteKey = isCustomEmoji ?
|
||||||
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
makeEmojiMuteKey({ name: extractCustomEmojiName(emoji), host: extractCustomEmojiHost(emoji) }) :
|
||||||
emoji;
|
emoji;
|
||||||
return computed(() => prefer.s.mutingEmojis.includes(emojiMuteKey));
|
return computed(() => prefer.r.mutingEmojis.value.includes(emojiMuteKey));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue