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

[stable30] fix(app-store): Update update count in navigation #48945

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Loading