refactor(files): Fix nullish operator usage and add missing code comment

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/45860/head
Ferdinand Thiessen 1 year ago
parent d4352fe2ff
commit 3782142f59
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 3
      apps/files/src/components/FileEntry/FileEntryActions.vue
  2. 4
      apps/files/src/components/FileEntryMixin.ts
  3. 5
      apps/files/src/utils/hashUtils.ts

@ -90,10 +90,9 @@ import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
import { useNavigation } from '../../composables/useNavigation'
import CustomElementRender from '../CustomElementRender.vue'
import { useNavigation } from '../../composables/useNavigation'
import logger from '../../logger.js'
// The registered actions list

@ -50,14 +50,14 @@ export default defineComponent({
computed: {
currentDir() {
// Remove any trailing slash but leave root slash
return (this.$route?.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
return (this.$route.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
},
currentFileId() {
return this.$route.params?.fileid || this.$route.query?.fileid || null
},
fileid() {
return this.source?.fileid
return this.source.fileid ?? 0
},
uniqueId() {
return hashCode(this.source.source)

@ -3,6 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
* Simple non-secure hashing function similar to Java's `hashCode`
* @param str The string to hash
* @return {number} a non secure hash of the string
*/
export const hashCode = function(str: string): number {
let hash = 0
for (let i = 0; i < str.length; i++) {

Loading…
Cancel
Save