mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
add modification after firt review part 1
This commit is contained in:
+6
-5
@@ -1,6 +1,7 @@
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { ChangelogVersion } from "renderer/services/auto-updater.service";
|
||||
import { LinkOpenerService } from "renderer/services/link-opener.service";
|
||||
import { useService } from "renderer/hooks/use-service.hook";
|
||||
import { ModalComponent } from "renderer/services/modale.service";
|
||||
import DOMPurify from 'dompurify';
|
||||
import './changelog-modal.component.css';
|
||||
@@ -8,7 +9,7 @@ import Tippy from "@tippyjs/react";
|
||||
|
||||
export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ resolver, data: changelog }) => {
|
||||
|
||||
const linkOpener: LinkOpenerService = LinkOpenerService.getInstance();
|
||||
const linkOpener = useService(LinkOpenerService);
|
||||
const openGithub = () => linkOpener.open("https://github.com/Zagrios/bs-manager");
|
||||
const openTwitter = () => linkOpener.open("https://twitter.com/BSManager_");
|
||||
const openSupportPage = () => linkOpener.open("https://www.patreon.com/bsmanager");
|
||||
@@ -27,16 +28,16 @@ export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ resolve
|
||||
</div>
|
||||
<div className="flex flex-row gap-2 my-auto">
|
||||
<Tippy content="Twitter" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
|
||||
<div><BsmButton onClick={openTwitter} className="rounded-md p-1 w-7 h-7" icon="twitter" withBar={false} typeColor="none" iconColor="#fff" color="#000"/></div>
|
||||
<div><BsmButton onClick={openTwitter} className="rounded-md p-1 w-7 h-7" icon="twitter" withBar={false} iconColor="#fff" color="#000"/></div>
|
||||
</Tippy>
|
||||
<Tippy content="Github" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
|
||||
<div><BsmButton onClick={openGithub} className="rounded-md p-1 w-7 h-7" icon="github" withBar={false} typeColor="none" iconColor="#fff" color="#000"/></div>
|
||||
<div><BsmButton onClick={openGithub} className="rounded-md p-1 w-7 h-7" icon="github" withBar={false} iconColor="#fff" color="#000"/></div>
|
||||
</Tippy>
|
||||
<Tippy content="Discord" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
|
||||
<div><BsmButton onClick={openDiscord} className="rounded-md p-1 w-7 h-7" icon="discord" withBar={false} typeColor="none" iconColor="#fff" color="#000"/></div>
|
||||
<div><BsmButton onClick={openDiscord} className="rounded-md p-1 w-7 h-7" icon="discord" withBar={false} iconColor="#fff" color="#000"/></div>
|
||||
</Tippy>
|
||||
<Tippy content="Patreon" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
|
||||
<div><BsmButton onClick={openSupportPage} className="rounded-md p-1 w-7 h-7 " icon="patreon" withBar={false} typeColor="none" iconColor="#fff" color="#000"/></div>
|
||||
<div><BsmButton onClick={openSupportPage} className="rounded-md p-1 w-7 h-7 " icon="patreon" withBar={false} iconColor="#fff" color="#000"/></div>
|
||||
</Tippy>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -66,10 +66,6 @@ export function BsmButton({ className, style, imgClassName, iconClassName, icon,
|
||||
if (typeColor === "success") {
|
||||
return "bg-green-500";
|
||||
}
|
||||
if (typeColor === "none")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
})();
|
||||
|
||||
|
||||
@@ -149,13 +149,12 @@ export function SettingsPage() {
|
||||
|
||||
const changelogPromise = autoUpdater.showChangelog(await lastValueFrom(autoUpdater.getAppVersion()))
|
||||
.then(() => {
|
||||
isChangelogResolved = true;
|
||||
setIsChangelogAvailable(() => true);
|
||||
})
|
||||
.catch(() => {
|
||||
isChangelogResolved = true;
|
||||
setIsChangelogAvailable(() => false);
|
||||
});
|
||||
})
|
||||
.finally(() => { isChangelogResolved = true; });
|
||||
|
||||
setTimeout(() => {
|
||||
setChanglogsLoading(() => !isChangelogResolved);
|
||||
@@ -471,13 +470,12 @@ export function SettingsPage() {
|
||||
</SettingContainer>
|
||||
</SettingContainer>
|
||||
<Tippy content={isChangelogAvailable !== false ? t("pages.settings.changelogs.open") : t("pages.settings.changelogs.not-founds")} placement="left" className="font-bold bg-main-color-3">
|
||||
<div className="bg-light-main-color-1 dark:bg-main-color-1 rounded-md py-1 px-2 font-bold float-right mb-5 hover:brightness-125 h-auto w-auto">
|
||||
<div className="!bg-light-main-color-1 dark:!bg-main-color-1 rounded-md py-1 px-2 font-bold float-right mb-5 hover:brightness-125 h-auto w-auto">
|
||||
<BsmButton onClick={handleVersionClick} text={`v${appVersion}`} withBar={false} typeColor="none"/>
|
||||
</div>
|
||||
</Tippy>
|
||||
<BsmImage className={`h-7 my-auto spin-loading float-right ${changlogsLoading ? "" : "hidden"}`} image={BeatWaitingImg} loading="eager" />
|
||||
</div>
|
||||
|
||||
<SupportersView isVisible={showSupporters} setVisible={setShowSupporters} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -71,7 +71,6 @@ export class AutoUpdaterService {
|
||||
}
|
||||
|
||||
private async getChangelog(): Promise<Changelog> {
|
||||
try {
|
||||
if (this.cacheChangelog) {
|
||||
return this.cacheChangelog;
|
||||
}
|
||||
@@ -79,28 +78,20 @@ export class AutoUpdaterService {
|
||||
const path = `https://raw.githubusercontent.com/Zagrios/bs-manager/feature/add-changelog-modal/178/assets/jsons/changelogs.json`
|
||||
const response = await fetch(path);
|
||||
if (!response.ok) {
|
||||
return undefined;
|
||||
throw new Error(`Failed to fetch changelogs (${response.status})`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
if (!data) {
|
||||
return undefined;
|
||||
throw new Error(`Failed to parse changelogs`);
|
||||
}
|
||||
|
||||
this.cacheChangelog = data;
|
||||
return data;
|
||||
}
|
||||
catch(error){
|
||||
this.ipcService.sendLazy("log-error", {args: error});
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private async getChangelogVersion(version:string): Promise<ChangelogVersion> {
|
||||
const changelogs = await this.getChangelog();
|
||||
if (!changelogs) {
|
||||
throw new Error(`No changelogs found`);
|
||||
}
|
||||
|
||||
const changelogVersion = changelogs[version];
|
||||
if (!changelogVersion) {
|
||||
@@ -119,4 +110,9 @@ export class AutoUpdaterService {
|
||||
|
||||
this.modal.openModal(ChangelogModal, changelog);
|
||||
}
|
||||
|
||||
lastValueFrom(autoUpdater.getAppVersion()).then(appVersion => {
|
||||
const lastAppVersion = autoUpdater.getLastAppVersion();
|
||||
if (!lastAppVersion) { return;}
|
||||
if(lte(appVersion,lastAppVersion)){ return; }
|
||||
}
|
||||
|
||||
@@ -40,10 +40,7 @@ export default function App() {
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
lastValueFrom(autoUpdater.getAppVersion()).then(appVersion => {
|
||||
const lastAppVersion = autoUpdater.getLastAppVersion();
|
||||
if (!lastAppVersion) { return;}
|
||||
if(lte(appVersion,lastAppVersion)){ return; }
|
||||
|
||||
autoUpdater.showChangelog(appVersion);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user