diff --git a/components/publish/PublishLanguagePicker.vue b/components/publish/PublishLanguagePicker.vue
index 57e1a7a3..bd7f139b 100644
--- a/components/publish/PublishLanguagePicker.vue
+++ b/components/publish/PublishLanguagePicker.vue
@@ -3,7 +3,7 @@ import ISO6391 from 'iso-639-1'
import Fuse from 'fuse.js'
let { modelValue } = $defineModel<{
- modelValue: string | null | undefined
+ modelValue: string
}>()
const { t } = useI18n()
@@ -11,17 +11,14 @@ const { t } = useI18n()
const languageKeyword = $ref('')
const languageList: {
- code: string | null
+ code: string
nativeName: string
- name?: string
-}[] = [{
- code: null,
- nativeName: t('language.none'),
-}, ...ISO6391.getAllCodes().map(code => ({
+ name: string
+}[] = ISO6391.getAllCodes().map(code => ({
code,
nativeName: ISO6391.getNativeName(code),
name: ISO6391.getName(code),
-}))]
+}))
const fuse = new Fuse(languageList, {
keys: ['code', 'nativeName', 'name'],
@@ -32,15 +29,11 @@ const languages = $computed(() =>
languageKeyword.trim()
? fuse.search(languageKeyword).map(r => r.item)
: [...languageList].sort(({ code: a }, { code: b }) => {
- return a === modelValue
- ? -1
- : b === modelValue
- ? 1
- : (a === null ? -1 : b === null ? 1 : a.localeCompare(b))
+ return a === modelValue ? -1 : b === modelValue ? 1 : a.localeCompare(b)
}),
)
-function chooseLanguage(language: string | null) {
+function chooseLanguage(language: string) {
modelValue = language
}
@@ -57,16 +50,11 @@ function chooseLanguage(language: string | null) {
- {{ nativeName }}
-
-
- {{ name }}
-
-
-
+ />
diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue
index 4d35d581..cb1c4ed1 100644
--- a/components/publish/PublishWidget.vue
+++ b/components/publish/PublishWidget.vue
@@ -333,9 +333,7 @@ defineExpose({
-
+
diff --git a/composables/statusDrafts.ts b/composables/statusDrafts.ts
index ec4c93bf..6c0e040f 100644
--- a/composables/statusDrafts.ts
+++ b/composables/statusDrafts.ts
@@ -1,32 +1,35 @@
-import type { Account, Status } from 'masto'
+import type { Account, CreateStatusParams, Status } from 'masto'
import { STORAGE_KEY_DRAFTS } from '~/constants'
import type { Draft, DraftMap } from '~/types'
+import type { Mutable } from '~/types/utils'
export const currentUserDrafts = process.server ? computed(() => ({})) : useUserLocalStorage(STORAGE_KEY_DRAFTS, () => ({}))
-export function getDefaultDraft(options: Partial> = {}): Draft {
+export function getDefaultDraft(options: Partial & Omit> = {}): Draft {
const {
- status = '',
- inReplyToId,
- visibility = 'public',
attachments = [],
initialText = '',
- sensitive = false,
- spoilerText = '',
+
+ status,
+ inReplyToId,
+ visibility,
+ sensitive,
+ spoilerText,
language,
} = options
return {
- params: {
- status,
- inReplyToId,
- visibility,
- sensitive,
- spoilerText,
- language,
- },
attachments,
initialText,
+
+ params: {
+ status: status || '',
+ inReplyToId,
+ visibility: visibility || 'public',
+ sensitive: sensitive ?? false,
+ spoilerText: spoilerText || '',
+ language: language || 'en',
+ },
}
}
diff --git a/composables/tiptap.ts b/composables/tiptap.ts
index 1886e6a5..fa610a31 100644
--- a/composables/tiptap.ts
+++ b/composables/tiptap.ts
@@ -18,7 +18,7 @@ import { CustomEmoji } from './tiptap/custom-emoji'
import { Emoji } from './tiptap/emoji'
export interface UseTiptapOptions {
- content: Ref
+ content: Ref
placeholder: Ref
onSubmit: () => void
onFocus: () => void
diff --git a/types/index.ts b/types/index.ts
index 67c2962e..7c38edf1 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -1,6 +1,6 @@
import type { Account, AccountCredentials, Attachment, CreateStatusParams, Emoji, Instance, MastoClient, Notification, PushSubscription, Status } from 'masto'
import type { Ref } from 'vue'
-import type { Mutable } from './utils'
+import type { MarkNonNullable, Mutable } from './utils'
export interface AppInfo {
id: string
@@ -59,9 +59,7 @@ export type TranslateFn = ReturnType['t']
export interface Draft {
editingStatus?: Status
initialText?: string
- params: Omit, 'status'> & {
- status?: Exclude
- }
+ params: MarkNonNullable, 'status' | 'language' | 'sensitive' | 'spoilerText' | 'visibility'>
attachments: Attachment[]
}
export type DraftMap = Record
diff --git a/types/utils.ts b/types/utils.ts
index e3bcb6cc..b95658fb 100644
--- a/types/utils.ts
+++ b/types/utils.ts
@@ -1,3 +1,8 @@
export type Mutable = {
-readonly[P in keyof T]: T[P]
}
+
+export type Overwrite = Omit & O
+export type MarkNonNullable = Overwrite
+}>