mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-04 04:57:51 +00:00 
			
		
		
		
	Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
		
			
				
	
	
		
			32 lines
		
	
	
		
			782 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			782 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { computed, unref } 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]);
 | 
						|
};
 | 
						|
 | 
						|
export const useFunctionGetter = (key, ...args) => {
 | 
						|
  const store = useStore();
 | 
						|
  return computed(() => {
 | 
						|
    const unrefedArgs = args.map(arg => unref(arg));
 | 
						|
    return store.getters[key](...unrefedArgs);
 | 
						|
  });
 | 
						|
};
 |