mirror of
https://github.com/lingble/chatwoot.git
synced 2025-12-03 19:43:43 +00:00
# Pull Request Template ## Description This PR will replace the usage of `conversation/labelMixin` with a composable Fixes https://linear.app/chatwoot/issue/CW-3439/rewrite-conversationlabelmixin-mixin-to-a-composable ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? **Test cases** 1. Add/remove labels from conversation sidebar 2. See labels are showing up dynamically 3. Check add/remove labels working fine with CMD bar 4. Check card labels in conversation card and SLA reports table. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
24 lines
558 B
JavaScript
24 lines
558 B
JavaScript
import { computed } from 'vue';
|
|
import { getCurrentInstance } from 'vue';
|
|
|
|
export const useStore = () => {
|
|
const vm = getCurrentInstance();
|
|
if (!vm) throw new Error('must be called in setup');
|
|
return vm.proxy.$store;
|
|
};
|
|
|
|
export const useStoreGetters = () => {
|
|
const store = useStore();
|
|
return Object.fromEntries(
|
|
Object.keys(store.getters).map(getter => [
|
|
getter,
|
|
computed(() => store.getters[getter]),
|
|
])
|
|
);
|
|
};
|
|
|
|
export const useMapGetter = key => {
|
|
const store = useStore();
|
|
return computed(() => store.getters[key]);
|
|
};
|