Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Also add current folder to button factory #1351

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jun 8, 2024

When picking directories and no node is selected the current directory is picked, this is correctly submitted but it is currently not correctly included in the button factory.

Meaning you can for example not check if you can pick the current directory (readonly directory).

Required for nextcloud/server#45688

@susnux susnux added bug Something isn't working 3. to review labels Jun 8, 2024
@susnux susnux requested review from artonge, Pytal and ShGKme June 8, 2024 11:52
@@ -189,7 +190,7 @@ const viewHeadline = computed(() => currentView.value === 'favorites' ? t('Favor
/**
* All currently selected files
*/
const selectedFiles = ref<Node[]>([])
const selectedFiles = shallowReactive<Node[]>([])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a shallow reactive, meaning the array is reactive, but not the inner elements.
This is required to fix Typescript, as Vue unrefs the inner nodes for ref which will strip off any private properties of the Node type. This causes Typescript issues as the types Ref<Node>.value != Node.

const navigatedPath = ref<string>()
const navigatedPath = ref('')
// Save the navigated path to the session storage on change
watch([navigatedPath], () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the writable computed below we can simply watch this and then react to it. Because doing login in writable computed properties seems to be bad.

@susnux susnux force-pushed the fix/add-current-folder-button-factory branch from 50adb46 to 000938d Compare June 8, 2024 11:57
@@ -114,7 +114,15 @@ export const useDAVFiles = function(
/**
* All files in current view and path
*/
const files = ref<Node[]>([] as Node[]) as Ref<Node[]>
const files = shallowRef<Node[]>([] as Node[]) as Ref<Node[]>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as for the shallowReactive but here we can use shallowRef because it only needs to be reactive on change of the value, we do not change the array.

@susnux susnux force-pushed the fix/add-current-folder-button-factory branch from 000938d to 70b3e6b Compare June 8, 2024 12:01
…`allowPickDirectory` is true

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/add-current-folder-button-factory branch from 70b3e6b to 110ddce Compare June 8, 2024 12:02
lib/components/types.ts Show resolved Hide resolved
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux merged commit 194cf83 into main Jun 10, 2024
10 checks passed
@susnux susnux deleted the fix/add-current-folder-button-factory branch June 10, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants