diff --git a/src/components/NotificationPreferenceModal.vue b/src/components/NotificationPreferenceModal.vue index 5ee91f96f..be5f8da9e 100644 --- a/src/components/NotificationPreferenceModal.vue +++ b/src/components/NotificationPreferenceModal.vue @@ -87,6 +87,7 @@ export default defineComponent({ }, computed: { ...mapGetters({ + userProfile: 'user/getUserProfile', currentFacility: 'user/getCurrentFacility', instanceUrl: 'user/getInstanceUrl', notificationPrefs: 'user/getNotificationPrefs' @@ -144,17 +145,17 @@ export default defineComponent({ } }, async handleTopicSubscription() { - const oms = this.instanceUrl + const ofbizInstanceName = this.userProfile.ofbizInstanceName const facilityId = (this.currentFacility as any).facilityId const subscribeRequests = [] as any this.notificationPrefToUpate.subscribe.map(async (enumId: string) => { - const topicName = generateTopicName(oms, facilityId, enumId) + const topicName = generateTopicName(ofbizInstanceName, facilityId, enumId) await subscribeRequests.push(subscribeTopic(topicName, process.env.VUE_APP_NOTIF_APP_ID)) }) const unsubscribeRequests = [] as any this.notificationPrefToUpate.unsubscribe.map(async (enumId: string) => { - const topicName = generateTopicName(oms, facilityId, enumId) + const topicName = generateTopicName(ofbizInstanceName, facilityId, enumId) await unsubscribeRequests.push(unsubscribeTopic(topicName, process.env.VUE_APP_NOTIF_APP_ID)) }) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 54a72c892..3d905ebc8 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -179,7 +179,7 @@ const actions: ActionTree = { async fetchNotificationPreferences({ commit, state }) { let resp = {} as any - const oms = state.instanceUrl + const ofbizInstanceName = state.current.ofbizInstanceName const facilityId = (state.currentFacility as any).facilityId let notificationPreferences = [], enumerationResp = [], userPrefIds = [] as any try { @@ -194,7 +194,7 @@ const actions: ActionTree = { // data and getNotificationUserPrefTypeIds fails or returns empty response (all disbaled) if (enumerationResp.length) { notificationPreferences = enumerationResp.reduce((notifactionPref: any, pref: any) => { - const userPrefTypeIdToSearch = generateTopicName(oms, facilityId, pref.enumId) + const userPrefTypeIdToSearch = generateTopicName(ofbizInstanceName, facilityId, pref.enumId) notifactionPref.push({ ...pref, isEnabled: userPrefIds.includes(userPrefTypeIdToSearch) }) return notifactionPref }, []) diff --git a/src/utils/firebase.ts b/src/utils/firebase.ts index bf903a7b2..6d027a0f3 100644 --- a/src/utils/firebase.ts +++ b/src/utils/firebase.ts @@ -9,7 +9,7 @@ const addNotification = async (notification: any) => store.dispatch('user/addNot const generateDeviceId = () => (DateTime.now().toFormat('ddMMyy') + String(DateTime.now().toMillis()).slice(-6)) // topic name: oms-facilityId-enumId(enumCode) -const generateTopicName = (oms: string, facilityId: string, enumId: string) => `${oms}-${facilityId}-${enumId}` +const generateTopicName = (ofbizInstanceName: string, facilityId: string, enumId: string) => `${ofbizInstanceName}-${facilityId}-${enumId}` export { addNotification,