use client-only noteVisibilities type

This commit is contained in:
Lhcfl 2024-04-10 01:18:08 +08:00
parent e486715e9a
commit 6ee1049731
8 changed files with 27 additions and 15 deletions

View file

@ -304,7 +304,7 @@ import insertTextAtCursor from "insert-text-at-cursor";
import { length } from "stringz";
import { toASCII } from "punycode/";
import { acct } from "firefish-js";
import type { entities, languages, noteVisibilities } from "firefish-js";
import type { entities, languages } from "firefish-js";
import { throttle } from "throttle-debounce";
import XNoteSimple from "@/components/MkNoteSimple.vue";
import XNotePreview from "@/components/MkNotePreview.vue";
@ -340,6 +340,7 @@ import {
import type { MenuItem } from "@/types/menu";
import icon from "@/scripts/icon";
import MkVisibilityPicker from "@/components/MkVisibilityPicker.vue";
import type { NoteVisibility } from "@/types/client-types";
const modal = inject("modal");
@ -351,7 +352,7 @@ const props = withDefaults(
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: (typeof noteVisibilities)[number];
initialVisibility?: NoteVisibility;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;

View file

@ -21,9 +21,10 @@
<script lang="ts" setup>
import { shallowRef } from "vue";
import type { entities, languages, noteVisibilities } from "firefish-js";
import type { entities, languages } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import MkPostForm from "@/components/MkPostForm.vue";
import type { NoteVisibility } from "@/types/client-types";
const props = defineProps<{
reply?: entities.Note;
@ -32,7 +33,7 @@ const props = defineProps<{
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: (typeof noteVisibilities)[number];
initialVisibility?: NoteVisibility;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;

View file

@ -142,16 +142,16 @@
<script lang="ts" setup>
import { nextTick, ref, shallowRef, watch } from "vue";
import type { noteVisibilities } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
import type { NoteVisibility } from "@/types/client-types";
const modal = shallowRef<InstanceType<typeof MkModal>>();
const props = withDefaults(
defineProps<{
currentVisibility: (typeof noteVisibilities)[number];
currentVisibility: NoteVisibility;
currentLocalOnly: boolean;
src?: HTMLElement;
}>(),
@ -159,7 +159,7 @@ const props = withDefaults(
);
const emit = defineEmits<{
(ev: "changeVisibility", v: (typeof noteVisibilities)[number]): void;
(ev: "changeVisibility", v: NoteVisibility): void;
(ev: "changeLocalOnly", v: boolean): void;
(ev: "closed"): void;
}>();
@ -172,7 +172,7 @@ watch(localOnly, () => {
});
function choose(
visibility: (typeof noteVisibilities)[number] | "private",
visibility: NoteVisibility,
): void {
v.value = visibility;
emit("changeVisibility", visibility);

View file

@ -34,7 +34,7 @@ import { computed, ref } from "vue";
// SPECIFICATION: https://misskey-hub.net/docs/features/share-form.html
import type { entities } from "firefish-js";
import { acct, noteVisibilities } from "firefish-js";
import { acct } from "firefish-js";
import MkButton from "@/components/MkButton.vue";
import XPostForm from "@/components/MkPostForm.vue";
import * as os from "@/os";
@ -42,6 +42,8 @@ import { mainRouter } from "@/router";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
import type { NoteVisibility } from "@/types/client-types";
import { noteVisibilitiesClient } from "@/types/consts";
const urlParams = new URLSearchParams(window.location.search);
const localOnlyQuery = urlParams.get("localOnly");
@ -57,9 +59,9 @@ const renote = ref(null as entities.Note | null);
function isVisibility(
v: string | null,
): v is (typeof noteVisibilities)[number] {
): v is NoteVisibility {
if (v == null) return false;
return (noteVisibilities as readonly string[]).includes(v);
return (noteVisibilitiesClient as readonly string[]).includes(v);
}
const visibility = ref(

View file

@ -1,7 +1,6 @@
import { markRaw, ref } from "vue";
import { isSignedIn } from "./me";
import { Storage } from "./pizzax";
import type { noteVisibilities } from "firefish-js";
export const postFormActions = [];
export const userActions = [];
@ -76,7 +75,7 @@ export const defaultStore = markRaw(
},
defaultNoteVisibility: {
where: "account",
default: "public" as (typeof noteVisibilities)[number],
default: "public" as NoteVisibility,
},
defaultNoteLocalOnly: {
where: "account",
@ -124,7 +123,7 @@ export const defaultStore = markRaw(
},
visibility: {
where: "deviceAccount",
default: "public" as (typeof noteVisibilities)[number],
default: "public" as NoteVisibility,
},
localOnly: {
where: "deviceAccount",
@ -453,6 +452,7 @@ import darkTheme from "@/themes/d-rosepine.json5";
* Storage for configuration information that does not need to be constantly loaded into memory (non-reactive)
*/
import lightTheme from "@/themes/l-rosepinedawn.json5";
import { NoteVisibility } from "./types/client-types";
export class ColdDeviceStorage {
public static default = {

View file

@ -0,0 +1,3 @@
import type { noteVisibilities } from "firefish-js";
export type NoteVisibility = (typeof noteVisibilities)[number] | "private";

View file

@ -0,0 +1,6 @@
import { noteVisibilities } from "firefish-js";
import type { NoteVisibility } from "./client-types";
export const noteVisibilitiesClient: NoteVisibility[] = (
noteVisibilities as readonly NoteVisibility[]
).concat("private");

View file

@ -18,7 +18,6 @@ export const noteVisibilities = [
"home",
"followers",
"specified",
"private",
] as const;
export const mutedNoteReasons = ["word", "manual", "spam", "other"] as const;