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

chore(vue3): migrate event buses to mitt #3766

Merged
merged 1 commit into from
Jan 3, 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
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"debounce": "^1.2.1",
"downloadjs": "^1.4.7",
"ical.js": "^1.5.0",
"mitt": "^3.0.1",
"moment": "^2.29.4",
"p-limit": "^4.0.0",
"qr-image": "^3.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppContent/ContactsContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import ContactDetails from '../ContactDetails.vue'
import ContactsList from '../ContactsList.vue'
import IconContact from 'vue-material-design-icons/AccountMultiple.vue'
import RouterMixin from '../../mixins/RouterMixin.js'
import Vue from 'vue'
import mitt from 'mitt'

export default {
name: 'ContactsContent',
Expand Down Expand Up @@ -117,7 +117,7 @@ export default {
return {
searchQuery: '',
// communication for ContactListItem and ContactDetails (reload avatar)
reloadBus: new Vue(),
reloadBus: mitt(),
}
},

Expand Down
4 changes: 2 additions & 2 deletions src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- org, title -->
<template #subtitle>
<template v-if="isReadOnly">
<span v-html="formattedSubtitle" />

Check warning on line 68 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / eslint

'v-html' directive can lead to XSS attack
</template>
<template v-else>
<input id="contact-title"
Expand Down Expand Up @@ -230,7 +230,7 @@
<template #icon>
<IconMail :size="20" />
</template>
<ActionLink v-for="emailAddress in emailAddressList"

Check warning on line 233 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / eslint

Variable 'emailAddress' is already declared in the upper scope
:key="emailAddress"
:href="'mailto:' + emailAddress">
<template #icon>
Expand Down Expand Up @@ -373,7 +373,7 @@

import { stringify } from 'ical.js'
import qr from 'qr-image'
import Vue from 'vue'
import mitt from 'mitt'
import {
NcActions as Actions,
NcActionButton as ActionButton,
Expand Down Expand Up @@ -500,7 +500,7 @@
excludeFromBirthdayKey: 'x-nc-exclude-from-birthday-calendar',

// communication for ContactDetailsAddNewProp and ContactDetailsProperty
bus: new Vue(),
bus: mitt(),

Check warning on line 503 in src/components/ContactDetails.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails.vue#L503

Added line #L503 was not covered by tests
showMenuPopover: false,
profileEnabled,
isTalkEnabled,
Expand Down Expand Up @@ -965,7 +965,7 @@
/**
* Update this.localContact and set this.fixed
*
* @param {Contact} contact the contact to clone

Check warning on line 968 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / eslint

The type 'Contact' is undefined
*/
async updateLocalContact(contact) {
// create empty contact and copy inner data
Expand Down Expand Up @@ -1016,7 +1016,7 @@
/**
* Should display the property
*
* @param {Property} property the property to check

Check warning on line 1019 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / eslint

The type 'Property' is undefined
* @return {boolean}
*/
canDisplay(property) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ContactDetails/ContactDetailsAddNewProp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
/**
* Rfc props
*
* @return string[]

Check warning on line 142 in src/components/ContactDetails/ContactDetailsAddNewProp.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @return type
*/
propertiesOrder() {
return rfcProps.fieldOrder
Expand Down Expand Up @@ -195,11 +195,11 @@
},

created() {
this.bus.$on('add-prop', this.addProp)
this.bus.on('add-prop', this.addProp)
},

destroyed() {
this.bus.$off('add-prop', this.addProp)
this.bus.off('add-prop', this.addProp)

Check warning on line 202 in src/components/ContactDetails/ContactDetailsAddNewProp.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsAddNewProp.vue#L202

Added line #L202 was not covered by tests
},

methods: {
Expand All @@ -210,7 +210,7 @@
*/
async addProp(id) {
if (this.usedProperties.includes(id) && !this.properties[id].multiple) {
this.bus.$emit('focus-prop', id)
this.bus.emit('focus-prop', id)
return
}

Expand Down Expand Up @@ -240,7 +240,7 @@
}
}
this.moreActionsOpen = false
this.bus.$emit('focus-prop', id)
this.bus.emit('focus-prop', id)
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ContactDetails/ContactDetailsAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export default {

await this.loadPhotoUrl()

await this.reloadBus.$emit('reload-avatar', this.contact.key)
await this.reloadBus.emit('reload-avatar', this.contact.key)

this.loading = false
},
Expand Down Expand Up @@ -438,7 +438,7 @@ export default {
this.$store.dispatch('updateContact', this.contact)
// somehow the avatarUrl is not unavailable immediately, so we just set undefined
this.photoUrl = undefined
this.reloadBus.$emit('delete-avatar', this.contact.key)
this.reloadBus.emit('delete-avatar', this.contact.key)
},

/**
Expand Down Expand Up @@ -530,7 +530,7 @@ export default {

await this.loadPhotoUrl()

await this.reloadBus.$emit('reload-avatar', this.contact.key)
await this.reloadBus.emit('reload-avatar', this.contact.key)

// Notify user
showSuccess(t('contacts', 'Avatar downloaded from social network'))
Expand Down
4 changes: 2 additions & 2 deletions src/components/ContactDetails/ContactDetailsProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ export default {
},

created() {
this.bus.$on('focus-prop', this.onFocusProp)
this.bus.on('focus-prop', this.onFocusProp)
},

destroyed() {
this.bus.$off('focus-prop', this.onFocusProp)
this.bus.off('focus-prop', this.onFocusProp)
},

methods: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ContactsList/ContactsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
},

created() {
this.reloadBus.$on('reload-avatar', this.reloadAvatarUrl)
this.reloadBus.$on('delete-avatar', this.deleteAvatar)
this.reloadBus.on('reload-avatar', this.reloadAvatarUrl)
this.reloadBus.on('delete-avatar', this.deleteAvatar)

Check warning on line 74 in src/components/ContactsList/ContactsListItem.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactsList/ContactsListItem.vue#L73-L74

Added lines #L73 - L74 were not covered by tests
},
destroyed() {
this.reloadBus.$off('reload-avatar', this.reloadAvatarUrl)
this.reloadBus.$off('delete-avatar', this.deleteAvatar)
this.reloadBus.off('reload-avatar', this.reloadAvatarUrl)
this.reloadBus.off('delete-avatar', this.deleteAvatar)

Check warning on line 78 in src/components/ContactsList/ContactsListItem.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactsList/ContactsListItem.vue#L78

Added line #L78 was not covered by tests
},
async mounted() {
await this.loadAvatarUrl()
Expand Down
2 changes: 1 addition & 1 deletion src/components/Properties/PropertyTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
* @param {string} id type of prop
*/
onAddProp(id) {
this.bus.$emit('add-prop', id)
this.bus.emit('add-prop', id)
},
},
}
Expand Down
Loading