mirror of
https://github.com/Zaarrg/stremio-community-v5.git
synced 2026-01-11 20:10:31 +00:00
Fixed being stuck on splash screen
- Fixed being stuck on splash screen by adding retry attempts and running initShellCom on DomContentLoad as well. - Fixed installer installing into stremio-4 if stremio 4 is installed.
This commit is contained in:
parent
815fd22cb4
commit
2103fdde8a
2 changed files with 80 additions and 9 deletions
70
src/main.cpp
70
src/main.cpp
|
|
@ -155,7 +155,8 @@ static ULONG_PTR g_gdiplusToken = 0;
|
|||
// App Ready and Event Queue
|
||||
#define WM_NOTIFY_FLUSH (WM_USER + 101)
|
||||
static std::vector<json> g_pendingMessages;
|
||||
static bool g_isAppReady = false;
|
||||
static std::atomic<bool> g_isAppReady = false;
|
||||
static std::atomic<bool> g_waitStarted(false);
|
||||
|
||||
// Updater
|
||||
static std::atomic_bool g_updaterRunning = false;
|
||||
|
|
@ -834,7 +835,7 @@ static void AppStart()
|
|||
j["type"] ="shellVersion";
|
||||
j["value"] =APP_VERSION;
|
||||
SendToJS(j);
|
||||
|
||||
HideSplash();
|
||||
for(const auto& pendingMsg : g_pendingMessages) {
|
||||
SendToJS(pendingMsg);
|
||||
}
|
||||
|
|
@ -1699,17 +1700,60 @@ LONG WINAPI ExceptionFilter(EXCEPTION_POINTERS* ExceptionInfo) {
|
|||
// WebView2
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void WaitAndRefreshIfNeeded() {
|
||||
std::thread([](){
|
||||
int attempts = 15; // Number of total attempts
|
||||
int waitTime = 1; // Initial wait time in seconds
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(waitTime));
|
||||
std::cout << "[WEBVIEW]: Checking Web Page state..." << std::endl;
|
||||
if(!g_isAppReady) {
|
||||
refreshWeb(true);
|
||||
} else {
|
||||
std::cout << "[WEBVIEW]: Web Page ready!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
waitTime++;
|
||||
|
||||
for(int i = 1; i < attempts; ++i) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(waitTime));
|
||||
std::cout << "[WEBVIEW]: Checking Web Page state..." << std::endl;
|
||||
if (g_isAppReady) {
|
||||
std::cout << "[WEBVIEW]: Web Page ready!" << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << "[WEBVIEW]: Web Page not ready... Refreshing..." << std::endl;
|
||||
refreshWeb(true);
|
||||
waitTime++;
|
||||
}
|
||||
|
||||
if(!g_isAppReady) {
|
||||
AppendToCrashLog(L"[WEBVIEW]: Web page could not be loaded after multiple attempts.");
|
||||
MessageBoxW(
|
||||
nullptr,
|
||||
L"Web page could not be loaded after multiple attempts. Make sure the Web UI is reachable. Check Github for more details.",
|
||||
L"WebView2 Page load fail",
|
||||
MB_ICONERROR | MB_OK
|
||||
);
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
|
||||
static void SetupWebMessageHandler()
|
||||
{
|
||||
if(!g_webview)return;
|
||||
EventRegistrationToken navToken;
|
||||
g_webview->add_NavigationCompleted(
|
||||
Callback<ICoreWebView2NavigationCompletedEventHandler>(
|
||||
[](ICoreWebView2* snd, ICoreWebView2NavigationCompletedEventArgs* args)->HRESULT
|
||||
[](ICoreWebView2* sender, ICoreWebView2NavigationCompletedEventArgs* args)->HRESULT
|
||||
{
|
||||
snd->ExecuteScript(L"initShellComm();",nullptr);
|
||||
if (g_hSplash) {
|
||||
HideSplash();
|
||||
std::cout<<"[WEBVIEW]: Navigation Complete\n";
|
||||
if (!g_isAppReady) {
|
||||
sender->ExecuteScript(L"initShellComm();", nullptr);
|
||||
}
|
||||
if (g_hSplash && !g_waitStarted.exchange(true)) {
|
||||
WaitAndRefreshIfNeeded();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
|
@ -1717,6 +1761,20 @@ static void SetupWebMessageHandler()
|
|||
&navToken
|
||||
);
|
||||
|
||||
EventRegistrationToken domToken;
|
||||
g_webview->add_DOMContentLoaded(
|
||||
Callback<ICoreWebView2DOMContentLoadedEventHandler>(
|
||||
[](ICoreWebView2* sender, IUnknown* args) -> HRESULT {
|
||||
std::cout<<"[WEBVIEW]: DOM content loaded\n";
|
||||
if (!g_isAppReady) {
|
||||
sender->ExecuteScript(L"initShellComm();", nullptr);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
).Get(),
|
||||
&domToken
|
||||
);
|
||||
|
||||
EventRegistrationToken contextMenuToken;
|
||||
g_webview->add_ContextMenuRequested(
|
||||
Callback<ICoreWebView2ContextMenuRequestedEventHandler>(
|
||||
|
|
|
|||
|
|
@ -373,10 +373,24 @@ FunctionEnd
|
|||
; Install code ;
|
||||
; ------------------- ;
|
||||
Function .onInit ; check for previous version
|
||||
; Read the previous installation directory from registry
|
||||
ReadRegStr $0 HKCU "${UNINSTALL_KEY}" "InstallString"
|
||||
StrCmp $0 "" done
|
||||
StrCpy $INSTDIR $0
|
||||
|
||||
; If registry value is empty, skip version check
|
||||
StrCmp $0 "" done
|
||||
|
||||
; Expected installation directory for current major version (Stremio-5)
|
||||
StrCpy $R1 "$LOCALAPPDATA\Programs\LNV\Stremio-5"
|
||||
|
||||
; Check if the registry path matches the expected directory
|
||||
StrCmp $0 $R1 usePrev 0
|
||||
; If it doesn't match, likely an old version, so do not use $0
|
||||
Goto done
|
||||
|
||||
usePrev:
|
||||
; If registry path matches the expected path, use it
|
||||
StrCpy $INSTDIR $0
|
||||
done:
|
||||
${GetParameters} $Parameters
|
||||
ClearErrors
|
||||
${GetOptions} $Parameters "/addon" $R1
|
||||
|
|
@ -384,7 +398,6 @@ Function .onInit ; check for previous version
|
|||
FileOpen $0 "$INSTDIR\addons.txt" w
|
||||
FileWrite $0 "$R1"
|
||||
FileClose $0
|
||||
done:
|
||||
FunctionEnd
|
||||
|
||||
Section ; App Files
|
||||
|
|
|
|||
Loading…
Reference in a new issue