Skip to content

Commit

Permalink
Merge pull request #402 from TogetherCrew/fix-dynamicnft-bug
Browse files Browse the repository at this point in the history
fix: fix the global module update
  • Loading branch information
Behzad-rabiei authored Nov 13, 2024
2 parents 2e83166 + 83961c2 commit 0e7309d
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/services/module.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,27 @@ const updateModule = async (
): Promise<HydratedDocument<IModule>> => {
// Check if `options.platforms` is in the updateBody
if (updateBody.options && updateBody.options.platforms) {
// Iterate through each platform in the incoming update
for (const newPlatform of updateBody.options.platforms) {
const existingPlatform = module.options?.platforms.find((p) => p.name === newPlatform.name);

// If the platform already exists, update it
if (existingPlatform) {
existingPlatform.metadata = newPlatform.metadata;
} else {
// If the platform does not exist, add new
module.options?.platforms.push(newPlatform);
if (updateBody.options.platforms[0].name == undefined) {
{
const globalOption = module.options?.platforms[0];
console.log(globalOption);
if (globalOption) globalOption.metadata = updateBody.options.platforms[0].metadata;
else module.options?.platforms.push(updateBody.options.platforms[0]);
}
} else {
// Iterate through each platform in the incoming update
for (const newPlatform of updateBody.options.platforms) {
const existingPlatform = module.options?.platforms.find((p) => p.name === newPlatform.name);
if (existingPlatform) {
// If the platform already exists, update it
existingPlatform.metadata = newPlatform.metadata;
} else {
// If the platform does not exist, add new
module.options?.platforms.push(newPlatform);
}
}
}
}

// Other update operations can be handled here
return await module.save();
};

Expand Down

0 comments on commit 0e7309d

Please sign in to comment.