-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parent share fetching in sidebar
- Loading branch information
1 parent
684a466
commit b179bcf
Showing
11 changed files
with
91 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useIncomingParentShare' |
47 changes: 47 additions & 0 deletions
47
packages/web-app-files/src/composables/parentShare/useIncomingParentShare.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { buildShare } from '../../helpers/resources' | ||
import { useStore } from 'web-pkg/src/composables' | ||
import { useActiveLocation } from '../router' | ||
import { isLocationSharesActive } from '../../router' | ||
import { computed, ref, unref } from '@vue/composition-api' | ||
import { useTask } from 'vue-concurrency' | ||
import { clientService } from 'web-pkg/src/services' | ||
|
||
export function useIncomingParentShare() { | ||
const store = useStore() | ||
const incomingParentShare = ref(null) | ||
const sharesTree = computed(() => store.state.Files.sharesTree) | ||
const isSharedWithMeLocation = useActiveLocation(isLocationSharesActive, 'files-shares-with-me') | ||
|
||
const loadIncomingParentShare = useTask(function* (signal, resource) { | ||
console.log('resource', resource) | ||
let parentShare | ||
for (const shares of Object.values(unref(sharesTree)) as any) { | ||
parentShare = shares.find((s) => s.incoming) | ||
if (parentShare) { | ||
console.log('via incoming:', parentShare) | ||
incomingParentShare.value = parentShare | ||
return | ||
} | ||
} | ||
|
||
if (unref(isSharedWithMeLocation)) { | ||
incomingParentShare.value = resource.share | ||
console.log('via share obj', incomingParentShare.value) | ||
return | ||
} | ||
|
||
if (resource.shareId) { | ||
const parentShare = yield clientService.owncloudSdk.shares.getShare(resource.shareId) | ||
if (parentShare) { | ||
incomingParentShare.value = buildShare(parentShare.shareInfo, resource, true) | ||
console.log('via share id', incomingParentShare.value) | ||
return | ||
} | ||
} | ||
|
||
console.log('No parent share') | ||
incomingParentShare.value = null | ||
}) | ||
|
||
return { loadIncomingParentShare, incomingParentShare } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters