Update the series view command to be in greyscale if the user has not claimed the card #297
2 changed files with 9 additions and 1 deletions
|
@ -47,6 +47,14 @@ export default class Inventory extends AppBaseEntity {
|
||||||
return single;
|
return single;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async ExistsByCardNumberAndUserId(userId: string, cardNumber: string): Promise<boolean> {
|
||||||
|
const repository = AppDataSource.getRepository(Inventory);
|
||||||
|
|
||||||
|
const count = await repository.count({ where: { UserId: userId, CardNumber: cardNumber }});
|
||||||
|
|
||||||
|
return count != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static async FetchAllByUserId(userId: string): Promise<Inventory[]> {
|
public static async FetchAllByUserId(userId: string): Promise<Inventory[]> {
|
||||||
const repository = AppDataSource.getRepository(Inventory);
|
const repository = AppDataSource.getRepository(Inventory);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default class ImageHelper {
|
||||||
const imageData = await Jimp.read(filePath);
|
const imageData = await Jimp.read(filePath);
|
||||||
|
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
const claimed = await Inventory.FetchOneByCardNumberAndUserId(userId, card.id) != null;
|
const claimed = await Inventory.ExistsByCardNumberAndUserId(userId, card.id);
|
||||||
Vylpes marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
if (!claimed) {
|
if (!claimed) {
|
||||||
imageData.greyscale();
|
imageData.greyscale();
|
||||||
|
|
Loading…
Reference in a new issue
This should also actually check the Quantity of the inventory, not just if it exists