Skip to content

Commit

Permalink
fix: Fix some type errors and remove comment between v-if and v-else …
Browse files Browse the repository at this point in the history
…causing vue2 vite plugin to fail

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Dec 14, 2023
1 parent 64341b7 commit 5fc8a3b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
18 changes: 7 additions & 11 deletions cypress/components/ConflictPicker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import type { ConflictResolutionResult } from '../../lib'

import { File as NcFile } from '@nextcloud/files'
import { openConflictPicker } from '../../dist/index.mjs'
import { openConflictPicker } from '../../lib/index.ts'

describe('ConflictPicker rendering', () => {
let image: File

before(() => {
cy.fixture('image.jpg', 'binary').then((content) => {
content = Uint8Array.from(content, x => x.charCodeAt(0))
cy.fixture('image.jpg', null).then((content: Buffer) => {
image = new File([content], 'image.jpg', { type: 'image/jpeg' })
})
})
Expand All @@ -33,11 +32,9 @@ describe('ConflictPicker rendering', () => {
mtime: new Date('2021-01-01T00:00:00.000Z'),
})

openConflictPicker('Pictures', [image], [oldImage]).catch(() => {
// Ignore error
})
openConflictPicker('Pictures', [image], [oldImage]).catch(() => {})

cy.get('[data-cy-conflict-picker]').should('exist')
cy.get('[data-cy-conflict-picker]', { timeout: 10000 }).should('exist')
cy.get('[data-cy-conflict-picker] h2').should('have.text', '1 file conflict in Pictures')
cy.get('[data-cy-conflict-picker-form]').should('be.visible')

Expand All @@ -58,8 +55,7 @@ describe('ConflictPicker resolving', () => {

before(() => {
images = []
cy.fixture('image.jpg', 'binary').then((content) => {
content = Uint8Array.from(content, x => x.charCodeAt(0))
cy.fixture('image.jpg', null).then((content) => {
images.push(new File([content], 'image1.jpg', { type: 'image/jpeg' }))
images.push(new File([content], 'image2.jpg', { type: 'image/jpeg' }))
})
Expand Down Expand Up @@ -202,8 +198,8 @@ describe('ConflictPicker resolving', () => {
promise.then((results: ConflictResolutionResult) => {
expect(results.selected).to.have.length(0)
expect(results.renamed).to.have.length(2)
expect(results.renamed[0].name).to.equal('image1 (1).jpg')
expect(results.renamed[1].name).to.equal('image2 (1).jpg')
expect((results.renamed[0] as File).name).to.equal('image1 (1).jpg')
expect((results.renamed[1] as File).name).to.equal('image2 (1).jpg')

cy.get('[data-cy-conflict-picker]').should('not.exist')
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/components/UploadPicker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// dist file might not be built when running eslint only
// eslint-disable-next-line import/no-unresolved,n/no-missing-import
import { Folder, Permission, addNewFileMenuEntry, type Entry } from '@nextcloud/files'
import { UploadPicker, getUploader } from '../../dist/index.mjs'
import { UploadPicker, getUploader } from '../../lib/index.ts'
import { generateRemoteUrl } from '@nextcloud/router'

describe('UploadPicker rendering', () => {
Expand Down
2 changes: 0 additions & 2 deletions lib/components/UploadPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
</template>
{{ buttonName }}
</NcButton>

<!-- New file menu -->
<NcActions v-else
:menu-name="buttonName"
:menu-title="addLabel"
Expand Down
8 changes: 5 additions & 3 deletions lib/uploader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CanceledError, type AxiosError, type AxiosResponse } from 'axios'
import type { AxiosError, AxiosResponse } from 'axios'

import { CanceledError } from 'axios'
import { encodePath } from '@nextcloud/paths'
import { Folder, Permission } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
Expand Down Expand Up @@ -194,7 +196,7 @@ export class Uploader {

// Let's initialize a chunk upload
const tempUrl = await initChunkWorkspace(encodedDestinationFile)
const chunksQueue: Array<Promise<any>> = []
const chunksQueue: Array<Promise<void>> = []

// Generate chunks array
for (let chunk = 0; chunk < upload.chunks; chunk++) {
Expand All @@ -207,7 +209,7 @@ export class Uploader {
// Init request queue
const request = () => {
return uploadData(
`${tempUrl}/${chunk+1}`,
`${tempUrl}/${chunk + 1}`,
blob,
upload.signal,
() => this.updateStats(),
Expand Down

0 comments on commit 5fc8a3b

Please sign in to comment.