Skip to content

Commit

Permalink
fix(apps): Adjust apps for FilePickerBuilder changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Aug 19, 2023
1 parent 9e779c8 commit f839677
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
3 changes: 1 addition & 2 deletions apps/files/src/components/TransferOwnershipDialogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import logger from '../logger.js'

const picker = getFilePickerBuilder(t('files', 'Choose a file or folder to transfer'))
.setMultiSelect(false)
.setModal(true)
.setType(1)
.allowDirectories()
.build()
Expand Down Expand Up @@ -132,7 +131,7 @@ export default {
this.directoryPickerError = undefined

picker.pick()
.then(dir => dir === '' ? '/' : dir)
.then(paths => paths.length === 0 || paths[0] === '' ? '/' : paths[0])
.then(dir => {
logger.debug(`path ${dir} selected for transferring ownership`)
if (!dir.startsWith('/')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ export default {
const picker = getFilePickerBuilder(t('files', 'Choose a default folder for accepted shares'))
.startAt(this.readableDirectory)
.setMultiSelect(false)
.setModal(true)
.setType(1)
.setMimeTypeFilter(['httpd/unix-directory'])
.allowDirectories()
.build()

try {
// Init user folder picking
const dir = await picker.pick() || '/'
const dir = (await picker.pick())?.[0] || '/'
if (!dir.startsWith('/')) {
throw new Error(t('files', 'Invalid path selected'))
}
Expand Down
27 changes: 16 additions & 11 deletions apps/settings/src/components/PersonalInfo/AvatarSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const VALID_MIME_TYPES = ['image/png', 'image/jpeg']
const picker = getFilePickerBuilder(t('settings', 'Choose your profile picture'))
.setMultiSelect(false)
.setMimeTypeFilter(VALID_MIME_TYPES)
.setModal(true)
.setType(1)
.allowDirectories(false)
.build()
Expand Down Expand Up @@ -204,18 +203,24 @@ export default {
},

async openFilePicker() {
const path = await picker.pick()
this.loading = true
try {
const { data } = await axios.post(generateUrl('/avatar'), { path })
if (data.status === 'success') {
this.handleAvatarUpdate(false)
} else if (data.data === 'notsquare') {
const tempAvatar = generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(OC.requestToken) + '#' + Math.floor(Math.random() * 1000)
this.$refs.cropper.replace(tempAvatar)
this.showCropper = true
const path = await picker.pick()
this.loading = true

if (path.length > 0) {
const { data } = await axios.post(generateUrl('/avatar'), { path: path[0] })

if (data.status === 'success') {
this.handleAvatarUpdate(false)
} else if (data.data === 'notsquare') {
const tempAvatar = generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(OC.requestToken) + '#' + Math.floor(Math.random() * 1000)
this.$refs.cropper.replace(tempAvatar)
this.showCropper = true
} else {
showError(data.data.message)
this.cancel()
}
} else {
showError(data.data.message)
this.cancel()
}
} catch (e) {
Expand Down
3 changes: 1 addition & 2 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const defaultShippedBackground = loadState('theming', 'defaultShippedBackground'
const prefixWithBaseUrl = (url) => generateFilePath('theming', '', 'img/background/') + url
const picker = getFilePickerBuilder(t('theming', 'Select a background from your files'))
.setMultiSelect(false)
.setModal(true)
.setType(1)
.setMimeTypeFilter(['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml', 'image/svg'])
.build()
Expand Down Expand Up @@ -257,7 +256,7 @@ export default {
}, 200),

async pickFile() {
const path = await picker.pick()
const path = (await picker.pick())?.[0]
this.loading = 'custom'

// Extract primary color from image
Expand Down

0 comments on commit f839677

Please sign in to comment.