Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil committed Sep 20, 2023
1 parent 9cd315a commit 8aa45ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/shared/services/data-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions src/shared/services/project-data-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ export async function getProjectDataProvider<ProjectType extends ProjectTypes>(

// 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<ProjectDataProvider[ProjectType]>(pdpId);
if (!pdp) throw new Error(`Cannot create project data provider for project ID ${projectId}`);
return pdp;
Expand Down

0 comments on commit 8aa45ab

Please sign in to comment.