Redundant assignments fix

This commit is contained in:
Moyasee
2025-09-19 17:28:39 +03:00
parent 14fc764328
commit 501ca7190e
2 changed files with 29 additions and 21 deletions

View File

@@ -75,10 +75,13 @@ app.whenReady().then(async () => {
let color2 = "#7b68ee";
// Simple string parsing approach - more secure than regex
if (gradientCss.startsWith("linear-gradient(") && gradientCss.endsWith(")")) {
if (
gradientCss.startsWith("linear-gradient(") &&
gradientCss.endsWith(")")
) {
const content = gradientCss.slice(16, -1); // Remove "linear-gradient(" and ")"
const parts = content.split(",").map(part => part.trim());
const parts = content.split(",").map((part) => part.trim());
if (parts.length >= 3) {
direction = parts[0];
color1 = parts[1];
@@ -92,30 +95,30 @@ app.whenReady().then(async () => {
y2 = "100%";
if (direction === "to right") {
x1 = "0%";
y1 = "0%";
// x1 = "0%"; // Already set to default value
// y1 = "0%"; // Already set to default value
x2 = "100%";
y2 = "0%";
} else if (direction === "to bottom") {
x1 = "0%";
y1 = "0%";
// x1 = "0%"; // Already set to default value
// y1 = "0%"; // Already set to default value
x2 = "0%";
y2 = "100%";
} else if (direction === "45deg") {
x1 = "0%";
// x1 = "0%"; // Already set to default value
y1 = "100%";
x2 = "100%";
y2 = "0%";
} else if (direction === "135deg") {
x1 = "0%";
y1 = "0%";
// x1 = "0%"; // Already set to default value
// y1 = "0%"; // Already set to default value
x2 = "100%";
y2 = "100%";
// y2 = "100%"; // Already set to default value
} else if (direction === "225deg") {
x1 = "100%";
y1 = "0%";
// y1 = "0%"; // Already set to default value
x2 = "0%";
y2 = "100%";
// y2 = "100%"; // Already set to default value
} else if (direction === "315deg") {
x1 = "100%";
y1 = "100%";

View File

@@ -117,7 +117,9 @@ export function EditGameModal({
const prepareCustomGameAssets = (game: LibraryGame) => {
const iconUrl = iconPath ? `local:${iconPath}` : game.iconUrl;
const logoImageUrl = logoPath ? `local:${logoPath}` : game.logoImageUrl;
const libraryHeroImageUrl = heroPath ? `local:${heroPath}` : game.libraryHeroImageUrl;
const libraryHeroImageUrl = heroPath
? `local:${heroPath}`
: game.libraryHeroImageUrl;
return { iconUrl, logoImageUrl, libraryHeroImageUrl };
};
@@ -133,8 +135,9 @@ export function EditGameModal({
// Helper function to update custom game
const updateCustomGame = async (game: LibraryGame) => {
const { iconUrl, logoImageUrl, libraryHeroImageUrl } = prepareCustomGameAssets(game);
const { iconUrl, logoImageUrl, libraryHeroImageUrl } =
prepareCustomGameAssets(game);
return window.electron.updateCustomGame(
game.shop,
game.objectId,
@@ -147,8 +150,9 @@ export function EditGameModal({
// Helper function to update non-custom game
const updateNonCustomGame = async (game: LibraryGame) => {
const { customIconUrl, customLogoImageUrl, customHeroImageUrl } = prepareNonCustomGameAssets();
const { customIconUrl, customLogoImageUrl, customHeroImageUrl } =
prepareNonCustomGameAssets();
return window.electron.updateGameCustomAssets(
game.shop,
game.objectId,
@@ -168,9 +172,10 @@ export function EditGameModal({
setIsUpdating(true);
try {
const updatedGame = game.shop === "custom"
? await updateCustomGame(game)
: await updateNonCustomGame(game);
const updatedGame =
game.shop === "custom"
? await updateCustomGame(game)
: await updateNonCustomGame(game);
showSuccessToast(t("edit_custom_game_modal_success"));
onGameUpdated(updatedGame);