Skip to content

Commit

Permalink
Merge pull request #48871 from nextcloud/fix/app-store-reactivity
Browse files Browse the repository at this point in the history
fix(app-store): Update update count in navigation
  • Loading branch information
susnux authored Oct 28, 2024
2 parents d25a0a2 + 955f591 commit 98cf108
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 15 deletions.
16 changes: 14 additions & 2 deletions apps/settings/src/components/AppList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@

<script>
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { useAppsStore } from '../store/apps-store'
import AppItem from './AppList/AppItem.vue'
import pLimit from 'p-limit'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import AppManagement from '../mixins/AppManagement'

export default {
name: 'AppList',
Expand All @@ -151,13 +153,22 @@ export default {
NcButton,
},

mixins: [AppManagement],

props: {
category: {
type: String,
required: true,
},
},

setup() {
const store = useAppsStore()
return {
store,
}
},

data() {
return {
search: '',
Expand Down Expand Up @@ -304,8 +315,9 @@ export default {
const limit = pLimit(1)
this.apps
.filter(app => app.update)
.map(app => limit(() => this.$store.dispatch('updateApp', { appId: app.id })),
)
.map((app) => limit(() => {
this.update(app.id)
}))
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions apps/settings/src/components/AppList/AppItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
</template>

<script>
import { useAppsStore } from '../../store/apps-store.js'

import AppScore from './AppScore.vue'
import AppLevelBadge from './AppLevelBadge.vue'
import AppManagement from '../../mixins/AppManagement.js'
Expand Down Expand Up @@ -151,6 +153,10 @@ export default {
default: false,
},
},
setup() {
const store = useAppsStore()
return { store }
},
data() {
return {
isSelected: false,
Expand Down
5 changes: 4 additions & 1 deletion apps/settings/src/mixins/AppManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ export default {
},
update(appId) {
this.$store.dispatch('updateApp', { appId })
.then((response) => { rebuildNavigation() })
.catch((error) => { showError(error) })
.then(() => {
rebuildNavigation()
this.store.updateCount = Math.max(this.store.updateCount - 1, 0)
})
},
},
}
5 changes: 2 additions & 3 deletions apps/settings/src/views/AppStoreNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<NcIconSvgWrapper :path="APPSTORE_CATEGORY_ICONS.disabled" />
</template>
</NcAppNavigationItem>
<NcAppNavigationItem v-if="updateCount > 0"
<NcAppNavigationItem v-if="store.updateCount > 0"
id="app-category-updates"
:to="{ name: 'apps-category', params: { category: 'updates' } }"
:name="APPS_SECTION_ENUM.updates">
<template #counter>
<NcCounterBubble>{{ updateCount }}</NcCounterBubble>
<NcCounterBubble>{{ store.updateCount }}</NcCounterBubble>
</template>
<template #icon>
<NcIconSvgWrapper :path="APPSTORE_CATEGORY_ICONS.updates" />
Expand Down Expand Up @@ -114,7 +114,6 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'

import APPSTORE_CATEGORY_ICONS from '../constants/AppstoreCategoryIcons.ts'

const updateCount = loadState<number>('settings', 'appstoreUpdateCount', 0)
const appstoreEnabled = loadState<boolean>('settings', 'appstoreEnabled', true)
const developerDocsUrl = loadState<string>('settings', 'appstoreDeveloperDocs', '')

Expand Down
4 changes: 2 additions & 2 deletions dist/8737-8737.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/8737-8737.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-apps-view-4529.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-apps-view-4529.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

0 comments on commit 98cf108

Please sign in to comment.