Skip to content

Commit

Permalink
Fix type errors introduced by better type context in Nuxt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrRip committed Oct 16, 2024
1 parent eb36521 commit 1b85fd4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/admin/app/components/playlist/MainList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function modifyNext (currentTarget: ModifyTarget) {
const fields: Array<ModifyTarget['field']> = ['name', 'artist', 'payment_amount', 'language']
modifyingInput.value?.[0]?.blur()
modifyingTarget.value.id = currentTarget.id
modifyingTarget.value.field = fields[fields.findIndex(field => field === currentTarget.field) + 1]
modifyingTarget.value.field = fields[fields.findIndex(field => field === currentTarget.field) + 1] ?? null
nextTick(() => modifyingInput.value?.[0]?.focus())
}

Expand Down
22 changes: 15 additions & 7 deletions packages/admin/app/pages/playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ function backendPlaylistPublishChanges (changesIds: Set<Song['$id']>) {
)

function cleanup (changesId: Song['$id'], newId?: Song['$id']) {
// @ts-expect-error
backendPlaylistPublishChangesState.value[
backendPlaylistPublishChangesState.value.findIndex(_ => _.$id === changesId)
].state = 'succeeded'
if (newId) {
// @ts-expect-error
backendPlaylistPublishChangesState.value[
backendPlaylistPublishChangesState.value.findIndex(_ => _.$id === changesId)
].newId = newId
}
else {
// @ts-expect-error
backendPlaylistPublishChangesState.value[
backendPlaylistPublishChangesState.value.findIndex(_ => _.$id === changesId)
// @ts-expect-error
Expand All @@ -119,7 +122,9 @@ function backendPlaylistPublishChanges (changesIds: Set<Song['$id']>) {
}
function fail (changesId: Song['$id'], error: AppwriteException) {
const changesPublishStateIndex = backendPlaylistPublishChangesState.value.findIndex(_ => _.$id === changesId)
// @ts-expect-error
backendPlaylistPublishChangesState.value[changesPublishStateIndex].state = 'failed'
// @ts-expect-error
backendPlaylistPublishChangesState.value[changesPublishStateIndex].error = error
}
function backendPlaylistRefreshIfAllPublishingFinished () {
Expand All @@ -128,10 +133,13 @@ function backendPlaylistPublishChanges (changesIds: Set<Song['$id']>) {
.then(() => {
backendPlaylistPublishChangesState.value.forEach((_, index) => {
if (!_.newId) { return }
// @ts-expect-error
viewPlaylistChangesData.value[
viewPlaylistChangesData.value.findIndex(changes => changes.$id === _.$id)
].$id = _.newId
// @ts-expect-error
backendPlaylistPublishChangesState.value[index].$id = _.newId
// @ts-expect-error
delete backendPlaylistPublishChangesState.value[index].newId
})
})
Expand Down Expand Up @@ -189,6 +197,7 @@ function viewPlaylistToggleSorting (column: PlaylistColumn) {
// Enable sorting or switch to another column
if (viewPlaylistSortingColumn.value === null || column !== viewPlaylistSortingColumn.value) {
viewPlaylistSortingColumn.value = column
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[0]
}
else
Expand All @@ -198,16 +207,15 @@ function viewPlaylistToggleSorting (column: PlaylistColumn) {
viewPlaylistSortingOrder.value === viewPlaylistSortingOrderOptions.value[viewPlaylistSortingOrderOptions.value.length - 1]
) {
viewPlaylistSortingColumn.value = null
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[0]
// Rotate between ordering options
}
// Rotate between ordering options
else {
const sortingOrderOptionIndex: number =
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1 >
viewPlaylistSortingOrderOptions.value.length - 1 ?
0 :
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[sortingOrderOptionIndex]
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1
]
}
viewPlaylistDataUpdate()
}
Expand Down
12 changes: 6 additions & 6 deletions packages/home/app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ function viewPlaylistToggleSorting (column: PlaylistColumn) {
// Enable sorting or switch to another column
if (viewPlaylistSortingColumn.value === null || column !== viewPlaylistSortingColumn.value) {
viewPlaylistSortingColumn.value = column
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[0]
}
else
Expand All @@ -336,16 +337,15 @@ function viewPlaylistToggleSorting (column: PlaylistColumn) {
viewPlaylistSortingOrder.value === viewPlaylistSortingOrderOptions.value[viewPlaylistSortingOrderOptions.value.length - 1]
) {
viewPlaylistSortingColumn.value = null
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[0]
}
// Rotate between ordering options
else {
const sortingOrderOptionIndex: number =
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1 >
viewPlaylistSortingOrderOptions.value.length - 1 ?
0 :
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[sortingOrderOptionIndex]
// @ts-expect-error
viewPlaylistSortingOrder.value = viewPlaylistSortingOrderOptions.value[
viewPlaylistSortingOrderOptions.value.findIndex(option => option === viewPlaylistSortingOrder.value) + 1
]
}
viewPlaylistDataUpdate(['sort'])
}
Expand Down

0 comments on commit 1b85fd4

Please sign in to comment.