Skip to content

Commit

Permalink
use userConfig store in all components
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Feb 15, 2024
1 parent bc85b66 commit d96558f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 88 deletions.
5 changes: 3 additions & 2 deletions src/components/FileLegacy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
<script>
import { generateUrl } from '@nextcloud/router'
import UserConfig from '../mixins/UserConfig.js'
export default {
name: 'FileLegacy',
mixins: [UserConfig],
inheritAttrs: false,
props: {
item: {
Expand Down Expand Up @@ -95,6 +93,9 @@ export default {
src() {
return generateUrl(`/core/preview?fileId=${this.item.injected.fileid}&c=${this.decodedEtag}&x=${250}&y=${250}&forceIcon=0&a=${this.croppedLayout ? '0' : '1'}`)
},
croppedLayout() {
return this.$store.state.userConfig.croppedLayout
},
},
beforeDestroy() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/FilesListViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ import TiledLayout from '../components/TiledLayout/TiledLayout.vue'
import { fetchFile } from '../services/fileFetcher.js'
import VirtualScrolling from '../components/VirtualScrolling.vue'
import EmptyBox from '../assets/Illustrations/empty.svg'
import UserConfig from '../mixins/UserConfig.js'
export default {
name: 'FilesListViewer',
Expand All @@ -100,8 +99,6 @@ export default {
VirtualScrolling,
},
mixins: [UserConfig],
props: {
// Array of file ids that should be rendered.
fileIds: {
Expand Down Expand Up @@ -222,6 +219,9 @@ export default {
showLoader() {
return this.loading && (this.fileIds?.length !== 0 || this.sections?.length !== 0)
},
croppedLayout() {
return this.$store.state.userConfig.croppedLayout
},
},
mounted() {
Expand Down
5 changes: 3 additions & 2 deletions src/components/PhotosPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ import File from './File.vue'
import FetchFilesMixin from '../mixins/FetchFilesMixin.js'
import FilesSelectionMixin from '../mixins/FilesSelectionMixin.js'
import FilesByMonthMixin from '../mixins/FilesByMonthMixin.js'
import UserConfig from '../mixins/UserConfig.js'
import allowedMimes from '../services/AllowedMimes.js'
export default defineComponent({
Expand All @@ -142,7 +141,6 @@ export default defineComponent({
FetchFilesMixin,
FilesByMonthMixin,
FilesSelectionMixin,
UserConfig,
],
props: {
Expand Down Expand Up @@ -243,6 +241,9 @@ export default defineComponent({
}
return moment(date, 'YYYYMM').format('MMMM YYYY')
},
photosLocationFolder() {
return this.$store.state.userConfig.photosLocationFolder
},
},
})
</script>
Expand Down
19 changes: 13 additions & 6 deletions src/components/Settings/CroppedLayoutSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
-->

<template>
<NcCheckboxRadioSwitch :checked.sync="croppedLayout"
<NcCheckboxRadioSwitch :checked="croppedLayout"
type="switch"
@update:checked="updateSetting('croppedLayout')">
@update:checked="updateSetting">
{{ t('photos', 'Enable squared photos view') }}
</NcCheckboxRadioSwitch>
</template>

<script>
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import UserConfig from '../../mixins/UserConfig.js'
export default {
name: 'CroppedLayoutSettings',
Expand All @@ -39,8 +38,16 @@ export default {
NcCheckboxRadioSwitch,
},
mixins: [
UserConfig,
],
computed: {
croppedLayout() {
return this.$store.state.userConfig.croppedLayout
},
},
methods: {
updateSetting(value) {
this.$store.dispatch('updateUserConfig', { key: 'croppedLayout', value })
},
},
}
</script>
73 changes: 0 additions & 73 deletions src/mixins/UserConfig.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/views/AlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
import FetchFilesMixin from '../mixins/FetchFilesMixin.js'
import FetchCollectionContentMixin from '../mixins/FetchCollectionContentMixin.js'
import UserConfig from '../mixins/UserConfig.js'
// import ActionDownload from '../components/Actions/ActionDownload.vue'
import ActionFavorite from '../components/Actions/ActionFavorite.vue'
Expand Down Expand Up @@ -232,7 +231,6 @@ export default {
FetchCollectionContentMixin,
FetchFilesMixin,
isMobile,
UserConfig,
],
props: {
Expand Down

0 comments on commit d96558f

Please sign in to comment.