Skip to content

Commit

Permalink
Fix missing information on share sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Sep 21, 2022
1 parent dacbb52 commit ea8b650
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 42 deletions.
59 changes: 18 additions & 41 deletions packages/web-app-files/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ import {
isLocationCommonActive,
isLocationPublicActive,
isLocationSharesActive,
isLocationSpacesActive,
isLocationTrashActive
isLocationSpacesActive
} from '../../router'
import { computed, defineComponent } from '@vue/composition-api'
import {
Expand Down Expand Up @@ -207,11 +206,8 @@ export default defineComponent({
watch: {
highlightedFile: {
handler(newFile, oldFile) {
if (!this.isSingleResource) {
return
}
if (oldFile && isEqual(newFile, oldFile)) {
const noChanges = oldFile && isEqual(newFile, oldFile)
if (!this.isSingleResource || !this.highlightedFile || noChanges) {
return
}
Expand All @@ -230,53 +226,34 @@ export default defineComponent({
deep: true
}
},
async created() {
if (!this.areMultipleSelected) {
await this.fetchFileInfo(false)
}
},
methods: {
...mapActions('Files', ['loadSharesTree']),
async fetchFileInfo(loadShares) {
if (!this.highlightedFile) {
this.selectedFile = {}
return
this.loading = true
const highlightedFileIsShare =
this.isSharedWithMeLocation ||
this.isSharedWithOthersLocation ||
this.isSharedViaLinkLocation
if (loadShares) {
this.loadShares()
}
if (
isLocationTrashActive(this.$router, 'files-trash-personal') ||
isLocationTrashActive(this.$router, 'files-trash-spaces-project') ||
this.highlightedFileIsSpace
) {
if (loadShares) {
this.loadShares()
}
if (!highlightedFileIsShare) {
this.selectedFile = { ...this.highlightedFile }
this.loading = false
return
}
this.loading = true
// shared resources look different, hence we need to fetch the actual resource here
try {
let item
if (isLocationPublicActive(this.$router, 'files-public-files')) {
item = await this.$client.publicFiles.getFileInfo(
this.highlightedFile.webDavPath,
this.publicLinkPassword,
DavProperties.PublicLink
)
} else {
item = await this.$client.files.fileInfo(
this.highlightedFile.webDavPath,
DavProperties.Default
)
}
const item = await this.$client.files.fileInfo(
this.highlightedFile.webDavPath,
DavProperties.Default
)
this.selectedFile = buildResource(item)
this.$set(this.selectedFile, 'thumbnail', this.highlightedFile.thumbnail || null)
if (loadShares) {
this.loadShares()
}
} catch (error) {
this.selectedFile = { ...this.highlightedFile }
console.error(error)
Expand Down
6 changes: 5 additions & 1 deletion packages/web-app-files/src/components/SideBar/SpaceInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
</template>

<script>
import { mapGetters } from 'vuex'
export default {
name: 'SpaceInfo',
inject: ['displayedItem'],
computed: {
...mapGetters('Files', ['highlightedFile']),
space() {
return this.displayedItem.value
return this.highlightedFile
}
}
}
Expand Down

0 comments on commit ea8b650

Please sign in to comment.