Skip to content

Commit

Permalink
fix: properly call store functions
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M. <[email protected]>
  • Loading branch information
enjeck committed Jan 22, 2025
1 parent 4f43877 commit 6fb10d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/modules/modals/ImportScheme.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export default {
}
axios.post(generateOcsUrl('/apps/tables/api/2/tables/scheme'), json).then(async res => {
if (res.status === 200) {
await this.loadTablesFromBE
await this.loadViewsSharedWithMeFromBE
await this.loadTablesFromBE()
await this.loadViewsSharedWithMeFromBE()
this.actionCancel()
return
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/modals/TransferContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div class="row">
<div class="fix-col-4 space-T end">
<NcButton type="warning" :disabled="newOwnerId === ''" data-cy="transferContextButton" @click="transferContext">
<NcButton type="warning" :disabled="newOwnerId === ''" data-cy="transferContextButton" @click="transferMe">
{{ t('tables', 'Transfer') }}
</NcButton>
</div>
Expand Down Expand Up @@ -71,7 +71,7 @@ export default {
actionCancel() {
this.$emit('close')
},
async transferContext() {
async transferMe() {
const transferId = this.context.id
const res = await this.transferContext({
id: this.context.id,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigation/partials/NavigationContextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default {
continue
}
hadAtLeastOneEntry = true
await this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode, target: 'self' })
await this.updateDisplayMode({ shareId: share.share_id, displayMode, target: 'self' })
this.showInNavigation = value
}
if (hadAtLeastOneEntry) {
Expand Down
15 changes: 10 additions & 5 deletions src/store/store.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { defineStore } from 'pinia'
import axios from '@nextcloud/axios'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
Expand Down Expand Up @@ -355,9 +360,9 @@ export const useTablesStore = defineStore('store', {
const createdShare = await axios.post(generateUrl('/apps/tables/share'), share)
if (createdShare?.data && createdShare?.data?.id) {
const shareId = createdShare.data.id
await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' })
await this.updateDisplayMode({ shareId, displayMode, target: 'default' })
if (receiver.id === getCurrentUser().uid) {
await dispatch('updateDisplayMode', { shareId, displayMode, target: 'self' })
await this.updateDisplayMode({ shareId, displayMode, target: 'self' })
}
}
}
Expand All @@ -376,15 +381,15 @@ export const useTablesStore = defineStore('store', {
await axios.delete(generateUrl('/apps/tables/share/' + previousReceiver.share_id))
} else {
const shareId = previousReceiver.share_id
await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' })
await this.updateDisplayMode({ shareId, displayMode, target: 'default' })
}
}
} catch (e) {
displayError(e, t('tables', 'Could not remove application share.'))
}
},

async updateDisplayMode({ dispatch }, { shareId, displayMode, target }) {
async updateDisplayMode({ shareId, displayMode, target }) {
try {
await axios.put(generateUrl('/apps/tables/share/' + shareId + '/display-mode'), { displayMode, target })
} catch (e) {
Expand Down Expand Up @@ -414,7 +419,7 @@ export const useTablesStore = defineStore('store', {
return res.data.ocs.data
},

async updateContext({ id, data, previousReceivers, receivers, receivers, displayMode }) {
async updateContext({ id, data, previousReceivers, receivers, displayMode }) {
let res = null
try {
res = await axios.put(generateOcsUrl('/apps/tables/api/2/contexts/' + id), data)
Expand Down

0 comments on commit 6fb10d3

Please sign in to comment.