Skip to content

Commit

Permalink
fix: issue #51
Browse files Browse the repository at this point in the history
  • Loading branch information
ResetPower committed Jan 30, 2022
1 parent 1944f0b commit 7c4fa53
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 249 deletions.
360 changes: 152 additions & 208 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "epherome",
"version": "0.3.1",
"version": "0.3.2",
"description": "Powerful Minecraft Launcher",
"main": "dist/main.js",
"scripts": {
Expand Down Expand Up @@ -69,12 +69,12 @@
"cssnano": "^5.0.16",
"electron": "^16.0.8",
"electron-builder": "^22.14.5",
"eslint": "^8.7.0",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"fork-ts-checker-webpack-plugin": "^7.0.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.5.3",
"node-loader": "^2.0.0",
Expand All @@ -83,7 +83,7 @@
"postcss-loader": "^6.2.1",
"prettier": "^2.5.1",
"react-refresh": "^0.11.0",
"tailwindcss": "^3.0.17",
"tailwindcss": "^3.0.18",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"typescript": "^4.5.5",
Expand Down
6 changes: 4 additions & 2 deletions src/common/struct/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MinecraftProfile } from "./profiles";
import { MinecraftAccount } from "./accounts";
import { Java } from "./java";
import { extendObservable, observable, runInAction, toJS } from "mobx";
import { action, extendObservable, observable, runInAction, toJS } from "mobx";
import { MinecraftDownloadProvider } from "core/url";
import log4js from "log4js";
import log4jsConfiguration from "common/utils/logging";
Expand Down Expand Up @@ -53,8 +53,10 @@ export class ConfigStore {
@observable titleBarStyle: TitleBarStyle = "os";
@observable checkUpdate = true;
constructor(preferred: Partial<unknown>) {
extendObservable(this, preferred);
const defaultConfig = toJS(this);
extendObservable(this, { ...defaultConfig, ...preferred });
}
@action
setConfig = (cb: (store: ConfigStore) => unknown, save = true): void => {
runInAction(() => cb(this));
save && this.save();
Expand Down
7 changes: 5 additions & 2 deletions src/common/struct/news.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { rendererLogger } from "common/loggers";
import { promisify } from "util";

export interface NewItem {
title: string;
Expand All @@ -11,7 +10,11 @@ export interface NewItem {
export async function fetchNews(): Promise<NewItem[] | null> {
rendererLogger.info("Fetching news...");
try {
const result = await promisify(window.native.fetchNews)();
const result = await new Promise<NewItem[]>((resolve, reject) =>
window.native.fetchNews((err, data) => {
data ? resolve(data) : reject(err);
})
);
rendererLogger.info("Fetched news");
return result ?? [];
} catch {
Expand Down
5 changes: 2 additions & 3 deletions src/common/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function parallelDownload(
itemList: ParallelDownloadItemWithoutUnique[],
onDetailsChange: DownloaderDetailsListener,
concurrency: number,
canceller?: Canceller
canceller: Canceller
): Promise<void> {
const counter = new Counter();
const items = itemList.map((i) => ({ ...i, unique: counter.count() }));
Expand All @@ -90,7 +90,7 @@ export async function parallelDownload(
const limit = pLimit(concurrency);
const promises = items.map((item) =>
limit(async () => {
if (canceller?.cancelled) {
if (canceller.cancelled) {
return;
}
const downloadStream = got.stream(item.url);
Expand All @@ -112,7 +112,6 @@ export async function parallelDownload(
canceller &&
canceller.update(() => {
downloadStream.destroy();
fileWriterStream.close();
fileWriterStream.destroy();
fs.rmSync(item.target);
});
Expand Down
6 changes: 3 additions & 3 deletions src/eph/intl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export class IntlStore {
@observable language?: Language;
constructor(languages: Language[], fallback: string) {
this.languages = languages;
this.setLanguage(fallback);
this.setLanguage(fallback, false);
makeObservable(this);
}
@action
setLanguage(name: string): void {
setLanguage(name: string, save?: boolean): void {
this.language = this.languages.find((val) => val.name === name);
setConfig((cfg) => (cfg.language = name));
setConfig((cfg) => (cfg.language = name), save);
}
}

Expand Down
49 changes: 25 additions & 24 deletions src/eph/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,32 @@ export const EphAppBar = observer(
)}
</div>
<AppBarTitle>{title}</AppBarTitle>
<TaskPanelShower />
{configStore.developerMode && (
<Menu
className="right-1"
items={[
{
icon: <VscDebugConsole />,
text: "Developer Tools",
action: () => ipcRenderer.send("open-devtools"),
},
{
icon: <MdRefresh />,
text: "Reload Epherome",
action: () => location.reload(),
},
]}
>
{(open) => (
<IconButton active={open}>
<MdDeveloperBoard />
</IconButton>
)}
</Menu>
)}

<div className="eph-no-drag flex">
<TaskPanelShower />
{configStore.developerMode && (
<Menu
className="right-1"
items={[
{
icon: <VscDebugConsole />,
text: "Developer Tools",
action: () => ipcRenderer.send("open-devtools"),
},
{
icon: <MdRefresh />,
text: "Reload Epherome",
action: () => location.reload(),
},
]}
>
{(open) => (
<IconButton active={open}>
<MdDeveloperBoard />
</IconButton>
)}
</Menu>
)}
{isTitleBarEph && (
<>
<IconButton onClick={() => ipcRenderer.send("minimize")}>
Expand Down
2 changes: 1 addition & 1 deletion src/eph/views/ProfileManagers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export const ProfileSettingsFragment = observer(
{manager.options
? manager.options.map(
(value, index) =>
value.key.includes(query) && (
value.key.toLowerCase().includes(query.toLowerCase()) && (
<div key={index} className="flex">
<Highlight
keyword={query}
Expand Down
5 changes: 4 additions & 1 deletion src/eph/views/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ export const SettingsGeneralFragment = observer(() => {
<FaJava /> {t("java.manage")}
</Button>
<Checkbox
checked={configStore.developerMode}
checked={(() => {
console.log(configStore.developerMode);
return configStore.developerMode;
})()}
onChange={(checked) =>
setConfig((cfg) => (cfg.developerMode = checked))
}
Expand Down
1 change: 0 additions & 1 deletion src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function readConfig() {
} else if (parsed.theme === "dark") {
parsed.theme = "RCS Dark";
}
fs.writeFileSync(configPath, JSON.stringify(parsed));
return parsed;
}

Expand Down

0 comments on commit 7c4fa53

Please sign in to comment.