Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hydralauncher/hydra
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrannychaseroperation committed Nov 9, 2024
2 parents 341903f + 20c0019 commit 1980560
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 854 deletions.
3 changes: 2 additions & 1 deletion src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
"blocked_users": "Blocked users",
"user_unblocked": "User has been unblocked",
"enable_achievement_notifications": "When an achievement is unlocked",
"launch_minimized": "Launch Hydra minimized"
"launch_minimized": "Launch Hydra minimized",
"disable_nsfw_alert": "Disable NSFW alert"
},
"notifications": {
"download_complete": "Download complete",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/pt-BR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@
"blocked_users": "Usuários bloqueados",
"user_unblocked": "Usuário desbloqueado",
"enable_achievement_notifications": "Quando uma conquista é desbloqueada",
"launch_minimized": "Iniciar o Hydra minimizado"
"launch_minimized": "Iniciar o Hydra minimizado",
"disable_nsfw_alert": "Desativar alerta de conteúdo inapropriado"
},
"notifications": {
"download_complete": "Download concluído",
Expand Down
8 changes: 4 additions & 4 deletions src/main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export const LUDUSAVI_MANIFEST_URL = "https://cdn.losbroxas.org/manifest.yaml";

export const defaultDownloadsPath = app.getPath("downloads");

export const isStaging = import.meta.env.MAIN_VITE_API_URL.includes("staging");

export const databaseDirectory = path.join(app.getPath("appData"), "hydra");
export const databasePath = path.join(
databaseDirectory,
import.meta.env.MAIN_VITE_API_URL.includes("staging")
? "hydra_test.db"
: "hydra.db"
isStaging ? "hydra_test.db" : "hydra.db"
);

export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
Expand All @@ -25,4 +25,4 @@ export const achievementSoundPath = app.isPackaged

export const backupsPath = path.join(app.getPath("userData"), "Backups");

export const appVersion = app.getVersion();
export const appVersion = app.getVersion() + (isStaging ? "-staging" : "");
3 changes: 3 additions & 0 deletions src/main/entity/user-preferences.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export class UserPreferences {
@Column("boolean", { default: false })
startMinimized: boolean;

@Column("boolean", { default: false })
disableNsfwAlert: boolean;

@CreateDateColumn()
createdAt: Date;

Expand Down
11 changes: 9 additions & 2 deletions src/main/events/misc/open-checkout.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { shell } from "electron";
import { registerEvent } from "../register-event";
import { userAuthRepository } from "@main/repository";
import {
userAuthRepository,
userPreferencesRepository,
} from "@main/repository";
import { HydraApi } from "@main/services";

const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
const [userAuth, userPreferences] = await Promise.all([
userAuthRepository.findOne({ where: { id: 1 } }),
userPreferencesRepository.findOne({ where: { id: 1 } }),
]);

if (!userAuth) {
return;
Expand All @@ -16,6 +22,7 @@ const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {

const params = new URLSearchParams({
token: paymentToken,
lng: userPreferences?.language || "en",
});

shell.openExternal(
Expand Down
2 changes: 2 additions & 0 deletions src/main/knex-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CreateUserSubscription } from "./migrations/20241015235142_create_user_
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
import { AddDisableNsfwAlertColumn } from "./migrations/20241106053733_add_disable_nsfw_alert_column";
export type HydraMigration = Knex.Migration & { name: string };

class MigrationSource implements Knex.MigrationSource<HydraMigration> {
Expand All @@ -28,6 +29,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
AddBackgroundImageUrl,
AddWinePrefixToGame,
AddStartMinimizedColumn,
AddDisableNsfwAlertColumn,
]);
}
getMigrationName(migration: HydraMigration): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";

export const AddDisableNsfwAlertColumn: HydraMigration = {
name: "AddDisableNsfwAlertColumn",
up: (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.boolean("disableNsfwAlert").notNullable().defaultTo(0);
});
},

down: async (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.dropColumn("disableNsfwAlert");
});
},
};
2 changes: 2 additions & 0 deletions src/main/services/hydra-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export class HydraApi {
expirationTimestamp: 0,
subscription: null,
};

this.post("/auth/logout", {}, { needsAuth: false }).catch(() => {});
}

static async setupApi() {
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export interface AppProps {
children: React.ReactNode;
}

console.log(import.meta.env);

Intercom({
app_id: import.meta.env.RENDERER_VITE_INTERCOM_APP_ID,
});
Expand Down
Loading

0 comments on commit 1980560

Please sign in to comment.