mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-22 08:14:07 +02:00
refactor(frontend): Formまわりの型強化 (#16260)
* refactor(frontend): Formまわりの型強化 * fix * avoid non-null assertion and add null check for safety * refactor * avoid non-null assertion and add null check for safety * Update clip.vue --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
@@ -76,7 +76,8 @@ watch(() => props.clipId, async () => {
|
||||
clip.value = await misskeyApi('clips/show', {
|
||||
clipId: props.clipId,
|
||||
});
|
||||
favorited.value = clip.value.isFavorited;
|
||||
|
||||
favorited.value = clip.value!.isFavorited ?? false;
|
||||
}, {
|
||||
immediate: true,
|
||||
});
|
||||
@@ -108,6 +109,8 @@ const headerActions = computed(() => clip.value && isOwned.value ? [{
|
||||
icon: 'ti ti-pencil',
|
||||
text: i18n.ts.edit,
|
||||
handler: async (): Promise<void> => {
|
||||
if (clip.value == null) return;
|
||||
|
||||
const { canceled, result } = await os.form(clip.value.name, {
|
||||
name: {
|
||||
type: 'string',
|
||||
@@ -128,6 +131,7 @@ const headerActions = computed(() => clip.value && isOwned.value ? [{
|
||||
default: clip.value.isPublic,
|
||||
},
|
||||
});
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
os.apiWithDialog('clips/update', {
|
||||
@@ -178,6 +182,8 @@ const headerActions = computed(() => clip.value && isOwned.value ? [{
|
||||
text: i18n.ts.delete,
|
||||
danger: true,
|
||||
handler: async (): Promise<void> => {
|
||||
if (clip.value == null) return;
|
||||
|
||||
const { canceled } = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.tsx.deleteAreYouSure({ x: clip.value.name }),
|
||||
|
||||
@@ -64,6 +64,7 @@ async function create() {
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
os.apiWithDialog('clips/create', result);
|
||||
|
||||
@@ -79,7 +79,9 @@ async function createKey() {
|
||||
default: scope.value.join('/'),
|
||||
},
|
||||
});
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
os.apiWithDialog('i/registry/set', {
|
||||
scope: result.scope.split('/'),
|
||||
key: result.key,
|
||||
|
||||
@@ -56,7 +56,9 @@ async function createKey() {
|
||||
label: i18n.ts._registry.scope,
|
||||
},
|
||||
});
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
os.apiWithDialog('i/registry/set', {
|
||||
scope: result.scope.split('/'),
|
||||
key: result.key,
|
||||
|
||||
Reference in New Issue
Block a user