refactor(files): Properly add type information to FilesListTableFooter

- Add correct type for `nodes` prop.
- Use `defineComponent` to properly infer Typescript information
- Correct usage of nullish coalescing operator

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/45585/head
Ferdinand Thiessen 2024-05-30 18:23:13 +07:00
parent 297f0522b2
commit e8adb97098
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
1 changed files with 8 additions and 8 deletions

@ -41,19 +41,19 @@
</template>
<script lang="ts">
import type { Node } from '@nextcloud/files'
import type { PropType } from 'vue'
import { formatFileSize } from '@nextcloud/files'
import { translate } from '@nextcloud/l10n'
import Vue from 'vue'
import { defineComponent } from 'vue'
import { useFilesStore } from '../store/files.ts'
import { usePathsStore } from '../store/paths.ts'
export default Vue.extend({
export default defineComponent({
name: 'FilesListTableFooter',
components: {
},
props: {
isMtimeAvailable: {
type: Boolean,
@ -64,7 +64,7 @@ export default Vue.extend({
default: false,
},
nodes: {
type: Array,
type: Array as PropType<Node[]>,
required: true,
},
summary: {
@ -104,7 +104,7 @@ export default Vue.extend({
if (this.dir === '/') {
return this.filesStore.getRoot(this.currentView.id)
}
const fileId = this.pathsStore.getPath(this.currentView.id, this.dir)
const fileId = this.pathsStore.getPath(this.currentView.id, this.dir)!
return this.filesStore.getNode(fileId)
},
@ -123,7 +123,7 @@ export default Vue.extend({
}
// Otherwise let's compute it
return formatFileSize(this.nodes.reduce((total, node) => total + node.size || 0, 0), true)
return formatFileSize(this.nodes.reduce((total, node) => total + (node.size ?? 0), 0), true)
},
},