pnpm format

This commit is contained in:
Kaity A 2023-05-07 11:52:18 +10:00
parent 99f15e3e1d
commit febb84645f
9 changed files with 69 additions and 36 deletions

View File

@ -16,7 +16,7 @@ export default async function renderNote(
dive = true,
isTalk = false,
): Promise<Record<string, unknown>> {
note.visibility = note.visibility === "hidden" ? "home" : note.visibility;
note.visibility = note.visibility === "hidden" ? "home" : note.visibility;
const getPromisedFiles = async (ids: string[]) => {
if (!ids || ids.length === 0) return [];
const items = await DriveFiles.findBy({ id: In(ids) });

View File

@ -606,8 +606,7 @@ export default async (
});
async function renderNoteOrRenoteActivity(data: Option, note: Note) {
if (data.localOnly ||
note.visibility !== "hidden") return null;
if (data.localOnly || note.visibility !== "hidden") return null;
const content =
data.renote &&

View File

@ -144,10 +144,7 @@ export default async (
});
//#region deliver
if (
Users.isLocalUser(user) &&
!note.localOnly
) {
if (Users.isLocalUser(user) && !note.localOnly) {
const content = renderActivity(await renderLike(record, note));
const dm = new DeliverManager(user, content);
if (note.userHost !== null) {

View File

@ -13,7 +13,12 @@
>
<template v-for="(item, i) in items2">
<div v-if="item === null" class="divider"></div>
<template v-else-if="item.hidden || item.visible !== undefined && !item.visible" />
<template
v-else-if="
item.hidden ||
(item.visible !== undefined && !item.visible)
"
/>
<span v-else-if="item.type === 'label'" class="label item">
<span :style="item.textStyle || ''">{{
item.text
@ -79,7 +84,10 @@
<button
v-else-if="item.type === 'user'"
class="_button item"
:class="{ active: item.active, ...classMap(item.classes) }"
:class="{
active: item.active,
...classMap(item.classes),
}"
:disabled="item.active"
@click="clicked(item.action, $event)"
@mouseenter.passive="onItemMouseEnter(item)"
@ -128,7 +136,10 @@
<button
v-else-if="item.type === 'parent'"
class="_button item parent"
:class="{ childShowing: childShowingItem === item, ...classMap(item.classes) }"
:class="{
childShowing: childShowingItem === item,
...classMap(item.classes),
}"
@mouseenter="showChildren(item, $event)"
@click="showChildren(item, $event)"
>
@ -149,7 +160,11 @@
<button
v-else
class="_button item"
:class="{ danger: item.danger, active: item.active, ...classMap(item.classes) }"
:class="{
danger: item.danger,
active: item.active,
...classMap(item.classes),
}"
:disabled="item.active"
@click="clicked(item.action, $event)"
@mouseenter.passive="onItemMouseEnter(item)"
@ -208,7 +223,13 @@ import {
import { focusPrev, focusNext } from "@/scripts/focus";
import FormSwitch from "@/components/form/switch.vue";
import FormInput from "@/components/form/input.vue";
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuClasses } from "@/types/menu";
import {
MenuItem,
InnerMenuItem,
MenuPending,
MenuAction,
MenuClasses,
} from "@/types/menu";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { FocusTrap } from "focus-trap-vue";
@ -269,14 +290,13 @@ let childTarget = $ref<HTMLElement | null>();
function classMap(classes?: MenuClasses) {
if (!classes) return {};
return (
Array.isArray(classes)
? classes
: classes.value
).reduce((acc, cls) => {
acc[cls] = true;
return acc;
}, {});
return (Array.isArray(classes) ? classes : classes.value).reduce(
(acc, cls) => {
acc[cls] = true;
return acc;
},
{}
);
}
function closeChild() {

View File

@ -49,14 +49,13 @@ let modal = $ref<InstanceType<typeof MkModal>>();
function classMap(classes?: MenuClasses) {
if (!classes) return {};
return (
Array.isArray(classes)
? classes
: classes.value
).reduce((acc, cls) => {
acc[cls] = true;
return acc;
}, {});
return (Array.isArray(classes) ? classes : classes.value).reduce(
(acc, cls) => {
acc[cls] = true;
return acc;
},
{}
);
}
</script>

View File

@ -41,7 +41,7 @@ const cwInput = ref<string>(props.renoteCw ?? "");
const canRenote = computed(
() =>
["public", "home","hidden"].includes(props.note.visibility) ||
["public", "home", "hidden"].includes(props.note.visibility) ||
props.note.userId === $i.id
);
@ -83,7 +83,10 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
let buttonActions: Array<MenuItem> = [];
if (props.note.visibility === "public" || props.note.visibility === "hidden") {
if (
props.note.visibility === "public" ||
props.note.visibility === "hidden"
) {
buttonActions.push({
text: i18n.ts.renote,
textStyle: "font-weight: bold",
@ -111,7 +114,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
});
}
if (["public", "home","hidden"].includes(props.note.visibility)) {
if (["public", "home", "hidden"].includes(props.note.visibility)) {
buttonActions.push({
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
icon: "ph-house ph-bold ph-lg",
@ -198,6 +201,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
type: "switch",
ref: addCw,
text: "Add content warning",
hidden: addCw,
});
buttonActions.push({
@ -238,7 +242,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
},
});
}
os.popupMenu(buttonActions, buttonRef.value, {
viaKeyboard,
});

View File

@ -97,7 +97,11 @@
<div v-if="appearNote.files.length > 0" class="files">
<XMediaList :media-list="appearNote.files" />
</div>
<XPoll v-if="appearNote.poll" :note="appearNote" class="poll" />
<XPoll
v-if="appearNote.poll"
:note="appearNote"
class="poll"
/>
<template v-if="detailed">
<MkUrlPreview
v-for="url in urls"

View File

@ -1,6 +1,13 @@
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
import { Component, markRaw, Ref, ref, defineAsyncComponent, ComputedRef } from "vue";
import {
Component,
markRaw,
Ref,
ref,
defineAsyncComponent,
ComputedRef,
} from "vue";
import { EventEmitter } from "eventemitter3";
import insertTextAtCursor from "insert-text-at-cursor";
import * as Misskey from "calckey-js";

View File

@ -1,12 +1,15 @@
import * as Misskey from "calckey-js";
import { ComputedRef, Ref } from "vue";
export type MenuClasses = Array<string> | Ref<Array<string>> | ComputedRef<Array<string>>;
export type MenuClasses =
| Array<string>
| Ref<Array<string>>
| ComputedRef<Array<string>>;
export type MenuBase = {
classes?: MenuClasses;
hidden?: boolean | Ref<boolean>;
visible?: boolean | Ref<boolean>;
}
};
export type MenuAction = (ev: MouseEvent) => void;