Skip to content

Commit

Permalink
Refactor character search logic in rankup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshinoai committed Sep 10, 2024
1 parent 2451df1 commit 314e050
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/controller/princess/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function fullRankup(context, props) {
const message = context.event.message.text;

const userOwnList = await inventoryModel.getAllUserOwnCharacters(userId);
const findResult = userOwnList.filter(character => character.name === name);
const findResult = userOwnList.find(character => character.name === name);
const filterResult = userOwnList.filter(character => character.name.includes(name));

if (!findResult && filterResult.length === 0) {
Expand Down Expand Up @@ -118,7 +118,7 @@ async function rankup(context, props) {
const message = context.event.message.text;

const userOwnList = await inventoryModel.getAllUserOwnCharacters(userId);
const findResult = userOwnList.filter(character => character.name === name);
const findResult = userOwnList.find(character => character.name === name);
const filterResult = userOwnList.filter(character => character.name.includes(name));

if (!findResult && filterResult.length === 0) {
Expand Down Expand Up @@ -191,7 +191,6 @@ async function rankup(context, props) {
},
}
);
context.replyText(convertUrl(character.headImage, costConfig.rank + 1));
}

/**
Expand Down

0 comments on commit 314e050

Please sign in to comment.