diff --git a/src/shared/services/data-provider.service.ts b/src/shared/services/data-provider.service.ts index f3b66fff53..7beb641f46 100644 --- a/src/shared/services/data-provider.service.ts +++ b/src/shared/services/data-provider.service.ts @@ -41,8 +41,14 @@ const ON_DID_UPDATE = 'onDidUpdate'; */ const SUBSCRIBE_PLACEHOLDER = {}; -/** Gets the id for the data provider network object with the given name */ -const getDataProviderObjectId = (providerName: string) => `${providerName}-${DATA_PROVIDER_LABEL}`; +/** Gets the id for the data provider network object with the given name + * Don't add the suffix to the provider name if it's already there to avoid duplication + */ +const getDataProviderObjectId = (providerName: string) => { + return providerName.endsWith(`-${DATA_PROVIDER_LABEL}`) + ? providerName + : `${providerName}-${DATA_PROVIDER_LABEL}`; +}; /** Whether this service has finished setting up */ let isInitialized = false; diff --git a/src/shared/services/project-data-provider.service.ts b/src/shared/services/project-data-provider.service.ts index 30338fdd2f..560fc71511 100644 --- a/src/shared/services/project-data-provider.service.ts +++ b/src/shared/services/project-data-provider.service.ts @@ -108,10 +108,7 @@ export async function getProjectDataProvider( // TODO: Get the appropriate PSI ID and pass it into pdpFactory.getProjectDataProviderId instead // of the storageType. https://github.com/paranext/paranext-core/issues/367 - let pdpId = await pdpFactory.getProjectDataProviderId(projectId, storageType); - // '-data' automatically gets appended, so we need to take it off or we get `-data-data` - const suffix: string = '-data'; - if (pdpId.endsWith(suffix)) pdpId = pdpId.substring(0, pdpId.length - suffix.length); + const pdpId = await pdpFactory.getProjectDataProviderId(projectId, storageType); const pdp = await dataProviderService.get(pdpId); if (!pdp) throw new Error(`Cannot create project data provider for project ID ${projectId}`); return pdp;