Skip to content

Commit

Permalink
chore(comments): register Pinia and clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Grigory Vodyanov <scratchx@gmx.com>
  • Loading branch information
GVodyanov committed Jun 17, 2024
1 parent 6ac6ff4 commit d6ba935
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 7 additions & 0 deletions apps/comments/src/comments-activity-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import Vue from 'vue'
import logger from './logger.js'
import { getComments } from './services/GetComments.js'

import { PiniaVuePlugin, createPinia } from 'pinia'

Vue.use(PiniaVuePlugin)

let ActivityTabPluginView
let ActivityTabPluginInstance

Expand All @@ -16,6 +20,8 @@ let ActivityTabPluginInstance
export function registerCommentsPlugins() {
window.OCA.Activity.registerSidebarAction({
mount: async (el, { context, fileInfo, reload }) => {
const pinia = createPinia()

if (!ActivityTabPluginView) {
const { default: ActivityCommmentAction } = await import('./views/ActivityCommentAction.vue')
ActivityTabPluginView = Vue.extend(ActivityCommmentAction)
Expand All @@ -26,6 +32,7 @@ export function registerCommentsPlugins() {
reloadCallback: reload,
resourceId: fileInfo.id,
},
pinia: pinia,
})
ActivityTabPluginInstance.$mount(el)
logger.info('Comments plugin mounted in Activity sidebar action', { fileInfo })
Expand Down
2 changes: 0 additions & 2 deletions apps/comments/src/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ export default {
},

isLimbo() {
console.log('checking for limbo', this.id)

return this.deletedCommentLimboStore.checkForId(this.id)
},
},
Expand Down
2 changes: 0 additions & 2 deletions apps/comments/src/mixins/CommentMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export default {

// DELETION
onDeleteWithUndo() {
console.log('DELETE WITH UNDO')
this.$emit('delete')
this.deleted = true
this.deletedCommentLimboStore.addId(this.id)
const timeOutDelete = setTimeout(this.onDelete, TOAST_UNDO_TIMEOUT)
Expand Down
4 changes: 1 addition & 3 deletions apps/comments/src/store/deletedCommentLimbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ export const useDeletedCommentLimbo = defineStore('deletedCommentLimbo', {
}),
actions: {
addId(id) {
console.log('ADDING ID TO LIMBO', id, this.idsInLimbo)
this.idsInLimbo.push(id)
},

removeId(id) {
console.log('REMOVING ID FROM LIMBO', id, this.idsInLimbo)
const index = this.idsInLimbo.indexOf(id)
if (index > -1) {
this.idsInLimbo.splice(index, 1)
}
},

checkForId(id) {
this.idsInLimbo.includes(id)
return this.idsInLimbo.includes(id)
}
},
})

0 comments on commit d6ba935

Please sign in to comment.