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

[stable28] fix: Load archived card if URL is opened directly #6324

Merged
merged 1 commit into from
Sep 17, 2024
Merged
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
10 changes: 10 additions & 0 deletions src/components/board/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ export default {
await this.$store.dispatch('loadBoardById', this.id)
await this.$store.dispatch('loadStacks', this.id)

const routeCardId = parseInt(this.$route.params.cardId)
// If an archived card is requested, and we cannot find it in the current we load the archived stacks instead
if (routeCardId && !this.$store.getters.cardById(routeCardId)) {
await this.$store.dispatch('loadArchivedStacks', this.id)

if (this.$store.getters.cardById(routeCardId)) {
this.$store.commit('toggleShowArchived', true)
}
}

this.session?.close()
this.session = createSession(this.id)
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export default new Vuex.Store({
}
})
},
toggleShowArchived(state) {
state.showArchived = !state.showArchived
toggleShowArchived(state, newState = undefined) {
state.showArchived = newState !== undefined ? newState : !state.showArchived
},
/*
* Adds or replaces a board in the store.
Expand Down
15 changes: 15 additions & 0 deletions src/store/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ export default {
}
commit('setCards', cards)
},
async loadArchivedStacks({ commit, getters }, boardId) {
const archivedStacks = await apiClient.loadArchivedStacks(boardId)
const cards = []
for (const i in archivedStacks) {
const stack = archivedStacks[i]
for (const j in stack.cards) {
cards.push(stack.cards[j])
}
delete stack.cards
if (!getters.stackById(stack.id)) {
commit('addStack', stack)
}
}
commit('setCards', cards)
},
createStack({ commit }, stack) {
stack.boardId = this.state.currentBoard.id
apiClient.createStack(stack)
Expand Down
Loading