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

Update favorites resources list on remove from favorites #9078

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-favorites-list-update-on-removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Favorites list update on removal

The Favorites list is now updating when a resource is removed from the list in this view

https://github.com/owncloud/web/pull/9078
4 changes: 4 additions & 0 deletions packages/web-app-files/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ClientService, LoadingTaskCallbackArguments } from 'web-pkg/src/service
import { Language } from 'vue3-gettext'
import { DavProperty } from 'web-client/src/webdav/constants'
import { AncestorMetaData } from 'web-app-files/src/helpers/resource/ancestorMetaData'
import { eventBus } from 'web-pkg/src/services/eventBus'

const allowSharePermissions = (getters) => {
return (
Expand Down Expand Up @@ -147,6 +148,9 @@ export default {
field: 'starred',
value: newValue
})
if (!newValue) {
eventBus.publish('app.files.list.removeFromFavorites')
}
})
.catch((error) => {
throw new Error(error)
Expand Down
16 changes: 13 additions & 3 deletions packages/web-app-files/src/views/Favorites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import FilesViewWrapper from '../components/FilesViewWrapper.vue'
import { useStore } from 'web-pkg/src/composables'
import { SpaceResource } from 'web-client/src/helpers'
import { getSpaceFromResource } from 'web-app-files/src/helpers/resource/getSpace'
import { eventBus } from 'web-pkg/src/services/eventBus'

const visibilityObserver = new VisibilityObserver()

Expand Down Expand Up @@ -117,11 +118,14 @@ export default defineComponent({
ViewModeConstants.tilesView
])

let loadResourcesEventToken

return {
...useFileActions(),
...useResourcesViewDefaults<Resource, any, any[]>(),
getSpace,
viewModes
viewModes,
loadResourcesEventToken
}
},

Expand All @@ -141,12 +145,18 @@ export default defineComponent({
},

async created() {
await this.loadResourcesTask.perform()
this.scrollToResourceFromRoute(this.paginatedResources)
this.loadResourcesEventToken = await eventBus.subscribe(
'app.files.list.removeFromFavorites',
async () => {
await this.loadResourcesTask.perform()
this.scrollToResourceFromRoute(this.paginatedResources)
}
)
},

beforeUnmount() {
visibilityObserver.disconnect()
eventBus.unsubscribe('app.files.list.removeFromFavorites', this.loadResourcesEventToken)
},

methods: {
Expand Down