Skip to content
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
2 changes: 2 additions & 0 deletions src/init-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { registerWidget, registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Functions/registerReference.js'
import { translate, translatePlural } from '@nextcloud/l10n'
import storeFactory from './store/main.js'

import './shared-init.js'

Expand Down Expand Up @@ -51,6 +52,7 @@ registerWidget('deck-board', async (el, { richObjectType, richObject, accessible
const { default: BoardReferenceWidget } = await import('./views/BoardReferenceWidget.vue')
const Widget = await prepareVue(BoardReferenceWidget)
boardWidgets[el] = new Widget({
store: storeFactory(),
propsData: {
richObjectType,
richObject,
Expand Down
6 changes: 4 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router.js'
import store from './store/main.js'
import storeFactory from './store/main.js'
import { sync } from 'vuex-router-sync'
import { translate, translatePlural } from '@nextcloud/l10n'
import { showError } from '@nextcloud/dialogs'
import { subscribe } from '@nextcloud/event-bus'
import ClickOutside from 'vue-click-outside'
import './shared-init.js'
import './models/index.js'
import './sessions.js'
import { initSessions } from './sessions.js'

// the server snap.js conflicts with vertical scrolling so we disable it
document.body.setAttribute('data-snap-ignore', 'true')

const store = storeFactory()
sync(store, router)
initSessions(store)

Vue.prototype.t = translate
Vue.prototype.n = translatePlural
Expand Down
42 changes: 25 additions & 17 deletions src/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { listen } from '@nextcloud/notify_push'
import { sessionApi } from './services/SessionApi.js'
import store from './store/main.js'
import axios from '@nextcloud/axios'

const SESSION_INTERVAL = 90 // in seconds
Expand All @@ -14,6 +13,8 @@ let hasPush = false

let syncRunning = false

let store = null

/**
* used to verify, whether an event is originated by ourselves
*
Expand All @@ -28,28 +29,35 @@ function isOurSessionToken(token) {
}
}

hasPush = listen('deck_board_update', (name, body) => {
// ignore update events which we have triggered ourselves
if (isOurSessionToken(body._causingSessionToken)) return
/**
*
* @param storeInstance
*/
export function initSessions(storeInstance) {
store = storeInstance
hasPush = listen('deck_board_update', (name, body) => {
// ignore update events which we have triggered ourselves
if (isOurSessionToken(body._causingSessionToken)) return

// only handle update events for the currently open board
const currentBoardId = store.state.currentBoard?.id
if (body.id !== currentBoardId) return
// only handle update events for the currently open board
const currentBoardId = store.state.currentBoard?.id
if (body.id !== currentBoardId) return

store.dispatch('refreshBoard', currentBoardId)
})
store.dispatch('refreshBoard', currentBoardId)
})

listen('deck_card_update', (name, body) => {
listen('deck_card_update', (name, body) => {

// ignore update events which we have triggered ourselves
if (isOurSessionToken(body._causingSessionToken)) return
// ignore update events which we have triggered ourselves
if (isOurSessionToken(body._causingSessionToken)) return

// only handle update events for the currently open board
const currentBoardId = store.state.currentBoard?.id
if (body.boardId !== currentBoardId) return
// only handle update events for the currently open board
const currentBoardId = store.state.currentBoard?.id
if (body.boardId !== currentBoardId) return

store.dispatch('loadStacks', currentBoardId)
})
store.dispatch('loadStacks', currentBoardId)
})
}

/**
* is the notify_push app active and can
Expand Down
Loading
Loading