From b67668e2851a32397b88c0b89849471aab33d5b1 Mon Sep 17 00:00:00 2001 From: Philip Wilk <50517631+wiryfuture@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:17:02 +0000 Subject: [PATCH] [General] Webview improvements and fixes (#836) * rule does not exist * improve webview responsiveness * completely block webview until state change * correct loginurl case removeEventListener ditto * Fix Creating Game Shortcuts on Linux * Fix Check for System Requirements #831 * Add MAC to CI build on Main * fixed discord RPC indicating macOS was "MacOS" (wrong capitalization use) (#837) * apply for all urls * resolve git conflict (hopefully) * fix case for login. also removes some imports. * forgorr to remove log :| * Update translation files Updated by "Squash Git commits" hook in Weblate. Update translation files Updated by "Squash Git commits" hook in Weblate. Co-authored-by: Hosted Weblate Translate-URL: https://hosted.weblate.org/projects/heroic-games-launcher/gamepage/ Translate-URL: https://hosted.weblate.org/projects/heroic-games-launcher/globals/ Translation: Heroic Games Launcher/GamePage Translation: Heroic Games Launcher/Globals * [General] Add Login with SID as alternative to Login with Epic (#875) * chore: wait before getting the sid * feat: add Login with sid as second option * 1i8n: updated keys * Revert "[General] Add Login with SID as alternative to Login with Epic (#875)" This reverts commit 4eefa9a3f9fcd1ff364183de9fa1df188bbb833a. * Revert "Update translation files" This reverts commit b1dc1bb237635ab9616338d56c4d35a9836e7854. * {} curlies after if * realign lock * fix webview URL, swap user agent spoofing to win10 * use did-stop-loading for url * update url to use did-navigate Co-authored-by: Flavio F Lima Co-authored-by: Andy Lin <60021592+andylin2004@users.noreply.github.com> Co-authored-by: Hosted Weblate --- downloadCount.js | 1 - src/components/UI/WebviewControls/index.tsx | 2 +- src/screens/WebView/index.css | 6 ++++++ src/screens/WebView/index.tsx | 15 ++++++--------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/downloadCount.js b/downloadCount.js index 26847c4731..fbbb5cd39f 100644 --- a/downloadCount.js +++ b/downloadCount.js @@ -1,4 +1,3 @@ -/* eslint-disable sort-keys-fix/sort-keys-fix */ /* eslint-disable @typescript-eslint/no-var-requires */ const axios = require('axios') const { writeFileSync } = require('graceful-fs') diff --git a/src/components/UI/WebviewControls/index.tsx b/src/components/UI/WebviewControls/index.tsx index 1c5675030e..42c618bbcb 100644 --- a/src/components/UI/WebviewControls/index.tsx +++ b/src/components/UI/WebviewControls/index.tsx @@ -16,7 +16,7 @@ export default function index({ webview, initURL }: Props) { const [url, setUrl] = React.useState(initURL) if (webview) { - webview.addEventListener('did-navigate-in-page', () => + webview.addEventListener('update-target-url', () => setUrl(webview.getURL()) ) } diff --git a/src/screens/WebView/index.css b/src/screens/WebView/index.css index 0bf8dd5521..d4aed70ca3 100644 --- a/src/screens/WebView/index.css +++ b/src/screens/WebView/index.css @@ -7,3 +7,9 @@ height: calc(100vh - 32px); margin-top: 32px; } + +webview { + position: absolute; + width: var(--content-width); + height: 100%; +} diff --git a/src/screens/WebView/index.tsx b/src/screens/WebView/index.tsx index 1ec667532b..33f8b9d479 100644 --- a/src/screens/WebView/index.tsx +++ b/src/screens/WebView/index.tsx @@ -1,17 +1,12 @@ import React, { useContext, useLayoutEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useLocation } from 'react-router' -import ElectronStore from 'electron-store' import { UpdateComponent } from 'src/components/UI' import WebviewControls from 'src/components/UI/WebviewControls' import ContextProvider from 'src/state/ContextProvider' import { Webview } from 'src/types' -const Store = window.require('electron-store') -const configStore: ElectronStore = new Store({ - cwd: 'store' -}) const { clipboard, ipcRenderer } = window.require('electron') import './index.css' @@ -24,7 +19,7 @@ type SID = { } const USER_AGENT = - 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.113 Safari/537.36 Vivaldi/5.0.2497.32' + 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.137 Safari/537.36' export default function WebView({ isLogin }: Props) { const { i18n } = useTranslation() @@ -35,7 +30,6 @@ export default function WebView({ isLogin }: Props) { refresh: boolean message: string }>({ refresh: true, message: t('loading.website', 'Loading Website') }) - const user = configStore.get('userInfo') let lang = i18n.language if (i18n.language === 'pt') { @@ -63,9 +57,12 @@ export default function WebView({ isLogin }: Props) { if (webview) { const loadstop = () => { setLoading({ ...loading, refresh: false }) - + // Ignore the login handling if not on login page + if (pathname !== '/') { + return + } // Deals with Login - if (!user) { + else { setTimeout(() => { webview.findInPage('sid') webview.addEventListener('found-in-page', async (res) => {