diff --git a/src/components/PrimaryLayout.vue b/src/components/PrimaryLayout.vue index c12c871..c079901 100644 --- a/src/components/PrimaryLayout.vue +++ b/src/components/PrimaryLayout.vue @@ -64,7 +64,7 @@ onMounted(async () => { // we need to fetch user data again. // eslint-disable-next-line @typescript-eslint/no-misused-promises await nextTick(async (): Promise => { - if (!userStore.publicKey) { + if (!(userStore.publicKey && userStore.holoportId)) { isLoading.value = true // eslint-disable-next-line @typescript-eslint/no-unsafe-call diff --git a/src/components/StopHostingModal.vue b/src/components/StopHostingModal.vue index f2325a9..e28dd5a 100644 --- a/src/components/StopHostingModal.vue +++ b/src/components/StopHostingModal.vue @@ -3,15 +3,16 @@ import { ExclamationCircleIcon, CheckCircleIcon } from '@heroicons/vue/24/outlin import BaseButton from '@uicommon/components/BaseButton' import BaseModal from '@uicommon/components/BaseModal' import { useModals } from '@uicommon/composables/useModals' -import { EButtonType } from '@uicommon/types/ui' import { ref } from 'vue' import { useI18n } from 'vue-i18n' import { EModal } from '@/constants/ui' +import { useUserStore } from '@/store/user' import { HAppDetails, useHposInterface } from '@/interfaces/HposInterface' import { isError as isErrorPredicate } from '@/types/predicates' const { t } = useI18n() const { stopHostingHApp, startHostingHApp } = useHposInterface() +const userStore = useUserStore() // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment const { showModal } = useModals() @@ -31,9 +32,9 @@ async function confirm(): Promise { let result = null if (props.hApp.enabled) { - result = await stopHostingHApp(props.hApp.id) + result = await stopHostingHApp(props.hApp.id, userStore.holoportId) } else { - result = await startHostingHApp(props.hApp.id) + result = await startHostingHApp(props.hApp.id, userStore.holoportId) } // If failed diff --git a/src/interfaces/HposInterface.ts b/src/interfaces/HposInterface.ts index f995ac7..d90e155 100644 --- a/src/interfaces/HposInterface.ts +++ b/src/interfaces/HposInterface.ts @@ -15,8 +15,8 @@ interface HposInterface { getUsage: () => Promise getHostedHApps: () => Promise getHAppDetails: (id: string) => Promise - startHostingHApp: (id: string) => Promise - stopHostingHApp: (id: string) => Promise + startHostingHApp: (id: string, hpId: string) => Promise + stopHostingHApp: (id: string, hpId: string) => Promise setDefaultHAppPreferences: (preferences: DefaultPreferencesPayload) => Promise updateHAppHostingPlan: (payload: UpdateHAppHostingPlanPayload) => Promise getHostEarnings: () => Promise @@ -476,13 +476,14 @@ export function useHposInterface(): HposInterface { } async function startHostingHApp( - id: string + id: string, + hpId: string ): Promise { try { const result = await hposHolochainCall({ method: 'post', pathPrefix: '/api/v2', - path: `/hosted_happs/${id}/enable` + path: `/hosted_happs/${id}/${hpId}enable` }) return result @@ -493,13 +494,14 @@ export function useHposInterface(): HposInterface { } async function stopHostingHApp( - id: string + id: string, + hpId: string ): Promise { try { const result = await hposHolochainCall({ method: 'post', pathPrefix: '/api/v2', - path: `/hosted_happs/${id}/disable` + path: `/hosted_happs/${id}/${hpId}enable` }) return result diff --git a/src/store/user.ts b/src/store/user.ts index 4802d92..549c166 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -13,6 +13,7 @@ const { getCoreAppVersion, getUser, updateHoloFuelProfile, updateHoloportName, g useHposInterface() interface State { + holoportId: string | undefined, publicKey: string | undefined email: string networkFlavour: string @@ -26,6 +27,7 @@ interface State { export const useUserStore = defineStore('user', { state: (): State => ({ + holoportId: undefined, publicKey: undefined, email: '', networkFlavour: '', @@ -67,6 +69,9 @@ export const useUserStore = defineStore('user', { if (coreAppVersion) { this.coreAppVersion = coreAppVersion } + + const hostUrl = window.location.host; + this.holoportId = hostUrl.split(".")[0] }, async updateHoloFuelProfile({