core/WebSocket: Delay websocket initialisation

Workaround for #16.
This commit is contained in:
Chris Josten 2024-01-02 15:36:19 +01:00
parent 3fb373a8ef
commit bb45637d0b
5 changed files with 110 additions and 38 deletions

View File

@ -44,7 +44,10 @@ WebSocket::WebSocket(ApiClient *client)
connect(client, &ApiClient::authenticatedChanged, this, [this](bool isAuthenticated) {
if (isAuthenticated) {
this->m_reconnectAttempt = 0;
this->open();
// https://github.com/heartfin/harbour-sailfin/issues/16
// Opening a websocket just afther the authentication may cause the application to freeze
// Therefore, we delay the initialisation :)
QTimer::singleShot(5'000, this, &WebSocket::open);
}
});
}

View File

@ -182,27 +182,12 @@ ApplicationWindow {
onAuthenticatedChanged: {
if (authenticated && !isInSetup()) {
console.log("Authenticated)")
loginAnimation.start()
//pageStack.replace(Qt.resolvedUrl("pages/MainPage.qml"))
//loginAnimation.start()
pageStack.replace(Qt.resolvedUrl("pages/MainPage.qml"))
}
}
}
// Delaying the creation of the MainPage prevents the application from freezing
// if connecting to the server over HTTPS
// TODO: figure out why the application actually freezes and remove this workaround
SequentialAnimation {
id: loginAnimation
PauseAnimation {
duration: 250
}
ScriptAction {
script: pageStack.replace(Qt.resolvedUrl("pages/MainPage.qml"), {}, PageStackAction.Immediate)
}
}
function isInSetup() {
return pageStack.find(function (page) { return typeof page._isSetupPage !== "undefined" }) !== null
}

View File

@ -115,6 +115,19 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ControllableDevicesPage</name>
<message>
<source>Remote control</source>
<extracomment>Page title: page for remote controlling other Jellyfin apps</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2</source>
<extracomment>List of devices item title in the form of &lt;app name&gt; &lt;device name&gt;</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -277,6 +290,11 @@
<source>Pull down to retry again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MusicAlbumPage</name>
@ -375,14 +393,6 @@ Page title for the list of all artists within the music library</extracomment>
</context>
<context>
<name>PlaybackBar</name>
<message>
<source>No media selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play some media!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No audio</source>
<translation type="unfinished"></translation>
@ -396,6 +406,20 @@ Page title for the list of all artists within the music library</extracomment>
<extracomment>Pulley menu item: stops playback of music</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nothing is playing</source>
<extracomment>Shown in a bright font when no media is playing in the bottom bar and now playing screen</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected to %1</source>
<extracomment>Shown when no media is being played, but the app is controlling another Jellyfin client %1 is the name of said client</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start playing some media!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PosterCover</name>

View File

@ -19,6 +19,10 @@
<source>&lt;p&gt;&lt;b&gt;Sailfin version %1&lt;/b&gt;&lt;br/&gt;Copyright © Chris Josten 2020%2&lt;/p&gt;&lt;p&gt;Sailfin is Free Software licensed under the &lt;a href=&apos;lgpl&apos;&gt;LGPL-v2.1&lt;/a&gt; or later, at your choice. Parts of the code of Sailfin are from other libraries. &lt;a href=&apos;3rdparty&apos;&gt;View their licenses here&lt;/a&gt;.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LGPL 2.1 License</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AddServerConnectingPage</name>
@ -115,6 +119,19 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ControllableDevicesPage</name>
<message>
<source>Remote control</source>
<extracomment>Page title: page for remote controlling other Jellyfin apps</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2</source>
<extracomment>List of devices item title in the form of &lt;app name&gt; &lt;device name&gt;</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DebugPage</name>
<message>
@ -255,6 +272,11 @@
<extracomment>Pulley menu item: reload items on page</extracomment>
<translation>Обновить</translation>
</message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MusicAlbumPage</name>
@ -357,11 +379,11 @@ Page title for the list of all artists within the music library</extracomment>
<name>PlaybackBar</name>
<message>
<source>No media selected</source>
<translation>Ничего не выбрано</translation>
<translation type="vanished">Ничего не выбрано</translation>
</message>
<message>
<source>Play some media!</source>
<translation>Начните что-то проигрывать!</translation>
<translation type="vanished">Начните что-то проигрывать!</translation>
</message>
<message>
<source>No audio</source>
@ -376,6 +398,20 @@ Page title for the list of all artists within the music library</extracomment>
<extracomment>Pulley menu item: stops playback of music</extracomment>
<translation>Стоп</translation>
</message>
<message>
<source>Nothing is playing</source>
<extracomment>Shown in a bright font when no media is playing in the bottom bar and now playing screen</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected to %1</source>
<extracomment>Shown when no media is being played, but the app is controlling another Jellyfin client %1 is the name of said client</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start playing some media!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PosterCover</name>
@ -518,7 +554,7 @@ This is still an alpha version :)</source>
<message>
<source>Network error</source>
<extracomment>Video playback error: network error</extracomment>
<translation type="unfinished"></translation>
<translation type="unfinished">Ошибка сети</translation>
</message>
<message>
<source>Access denied</source>
@ -533,7 +569,7 @@ This is still an alpha version :)</source>
<message>
<source>Retry</source>
<extracomment>Button to retry loading a video after a failure</extracomment>
<translation type="unfinished"></translation>
<translation type="unfinished">Попробовать снова</translation>
</message>
<message>
<source>No error</source>

View File

@ -115,6 +115,19 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ControllableDevicesPage</name>
<message>
<source>Remote control</source>
<extracomment>Page title: page for remote controlling other Jellyfin apps</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2</source>
<extracomment>List of devices item title in the form of &lt;app name&gt; &lt;device name&gt;</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DebugPage</name>
<message>
@ -255,6 +268,11 @@
<source>Pull down to retry again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MusicAlbumPage</name>
@ -353,14 +371,6 @@ Page title for the list of all artists within the music library</extracomment>
</context>
<context>
<name>PlaybackBar</name>
<message>
<source>No media selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play some media!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No audio</source>
<translation type="unfinished"></translation>
@ -374,6 +384,20 @@ Page title for the list of all artists within the music library</extracomment>
<extracomment>Pulley menu item: stops playback of music</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nothing is playing</source>
<extracomment>Shown in a bright font when no media is playing in the bottom bar and now playing screen</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected to %1</source>
<extracomment>Shown when no media is being played, but the app is controlling another Jellyfin client %1 is the name of said client</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start playing some media!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PosterCover</name>