hide muted threads behind a CW
This commit is contained in:
parent
87582034b5
commit
9bebf7718f
11 changed files with 83 additions and 47 deletions
|
|
@ -3,14 +3,34 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { inject, ref } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import { computed, inject, ref } from 'vue';
|
||||
import type { Ref, ComputedRef } from 'vue';
|
||||
import { $i } from '@/i';
|
||||
|
||||
export function checkMutes(noteToCheck: Misskey.entities.Note, withHardMute = false) {
|
||||
const muted = ref(checkMute(noteToCheck, $i?.mutedWords));
|
||||
const hardMuted = ref(withHardMute && checkMute(noteToCheck, $i?.hardMutedWords, true));
|
||||
return { muted, hardMuted };
|
||||
export function checkMutes(noteToCheck: ComputedRef<Misskey.entities.Note>, withHardMute?: ComputedRef<boolean>) {
|
||||
const muteEnable = ref(true);
|
||||
|
||||
const muted = computed<false | string[], boolean>({
|
||||
get() {
|
||||
if (!muteEnable.value) return false;
|
||||
return checkMute(noteToCheck.value, $i?.mutedWords);
|
||||
},
|
||||
set(value: boolean) {
|
||||
muteEnable.value = value;
|
||||
},
|
||||
});
|
||||
|
||||
const threadMuted = computed(() => {
|
||||
if (!muteEnable.value) return false;
|
||||
return noteToCheck.value.isMuting;
|
||||
});
|
||||
|
||||
const hardMuted = computed(() => {
|
||||
if (!withHardMute?.value) return false;
|
||||
return checkMute(noteToCheck.value, $i?.hardMutedWords, true);
|
||||
});
|
||||
|
||||
return { muted, hardMuted, threadMuted };
|
||||
}
|
||||
|
||||
export function checkMute(note: Misskey.entities.Note, mutes: undefined | null): false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue