Skip to content

Commit 7fec223

Browse files
committed
refactor(files): Fix nullish operator usage and add missing code comment
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent f2e3dcb commit 7fec223

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,14 @@ import type { PropType } from 'vue'
8181
import { DefaultType, FileAction, Node, NodeStatus, View, getFileActions } from '@nextcloud/files'
8282
import { showError, showSuccess } from '@nextcloud/dialogs'
8383
import { translate as t } from '@nextcloud/l10n'
84+
import { defineComponent } from 'vue'
8485
8586
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
8687
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
8788
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
8889
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
8990
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
9091
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
91-
import Vue, { defineComponent } from 'vue'
92-
9392
import CustomElementRender from '../CustomElementRender.vue'
9493
9594
import logger from '../../logger.js'
@@ -270,7 +269,7 @@ export default defineComponent({
270269
try {
271270
// Set the loading marker
272271
this.$emit('update:loading', action.id)
273-
Vue.set(this.source, 'status', NodeStatus.LOADING)
272+
this.$set(this.source, 'status', NodeStatus.LOADING)
274273
275274
const success = await action.exec(this.source, this.currentView, this.currentDir)
276275
@@ -290,7 +289,7 @@ export default defineComponent({
290289
} finally {
291290
// Reset the loading marker
292291
this.$emit('update:loading', '')
293-
Vue.set(this.source, 'status', undefined)
292+
this.$set(this.source, 'status', undefined)
294293
295294
// If that was a submenu, we just go back after the action
296295
if (isSubmenu) {

apps/files/src/components/FileEntryMixin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ export default defineComponent({
5454

5555
currentDir() {
5656
// Remove any trailing slash but leave root slash
57-
return (this.$route?.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
57+
return (this.$route.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
5858
},
5959
currentFileId() {
6060
return this.$route.params?.fileid || this.$route.query?.fileid || null
6161
},
6262

6363
fileid() {
64-
return this.source?.fileid
64+
return this.source.fileid ?? 0
6565
},
6666
uniqueId() {
6767
return hashCode(this.source.source)

apps/files/src/utils/hashUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
/**
7+
* Simple non-secure hashing function similar to Java's `hashCode`
8+
* @param str The string to hash
9+
* @return {number} a non secure hash of the string
10+
*/
611
export const hashCode = function(str: string): number {
712
let hash = 0
813
for (let i = 0; i < str.length; i++) {

0 commit comments

Comments
 (0)