1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-22 09:15:18 +00:00

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) { connect(client, &ApiClient::authenticatedChanged, this, [this](bool isAuthenticated) {
if (isAuthenticated) { if (isAuthenticated) {
this->m_reconnectAttempt = 0; 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: { onAuthenticatedChanged: {
if (authenticated && !isInSetup()) { if (authenticated && !isInSetup()) {
console.log("Authenticated)") console.log("Authenticated)")
loginAnimation.start() //loginAnimation.start()
//pageStack.replace(Qt.resolvedUrl("pages/MainPage.qml")) 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() { function isInSetup() {
return pageStack.find(function (page) { return typeof page._isSetupPage !== "undefined" }) !== null return pageStack.find(function (page) { return typeof page._isSetupPage !== "undefined" }) !== null
} }

View file

@ -115,6 +115,19 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>CoverPage</name> <name>CoverPage</name>
<message> <message>
@ -277,6 +290,11 @@
<source>Pull down to retry again</source> <source>Pull down to retry again</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MusicAlbumPage</name> <name>MusicAlbumPage</name>
@ -375,14 +393,6 @@ Page title for the list of all artists within the music library</extracomment>
</context> </context>
<context> <context>
<name>PlaybackBar</name> <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> <message>
<source>No audio</source> <source>No audio</source>
<translation type="unfinished"></translation> <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> <extracomment>Pulley menu item: stops playback of music</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>PosterCover</name> <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> <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> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>LGPL 2.1 License</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>AddServerConnectingPage</name> <name>AddServerConnectingPage</name>
@ -115,6 +119,19 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>DebugPage</name> <name>DebugPage</name>
<message> <message>
@ -255,6 +272,11 @@
<extracomment>Pulley menu item: reload items on page</extracomment> <extracomment>Pulley menu item: reload items on page</extracomment>
<translation>Обновить</translation> <translation>Обновить</translation>
</message> </message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MusicAlbumPage</name> <name>MusicAlbumPage</name>
@ -357,11 +379,11 @@ Page title for the list of all artists within the music library</extracomment>
<name>PlaybackBar</name> <name>PlaybackBar</name>
<message> <message>
<source>No media selected</source> <source>No media selected</source>
<translation>Ничего не выбрано</translation> <translation type="vanished">Ничего не выбрано</translation>
</message> </message>
<message> <message>
<source>Play some media!</source> <source>Play some media!</source>
<translation>Начните что-то проигрывать!</translation> <translation type="vanished">Начните что-то проигрывать!</translation>
</message> </message>
<message> <message>
<source>No audio</source> <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> <extracomment>Pulley menu item: stops playback of music</extracomment>
<translation>Стоп</translation> <translation>Стоп</translation>
</message> </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>
<context> <context>
<name>PosterCover</name> <name>PosterCover</name>
@ -518,7 +554,7 @@ This is still an alpha version :)</source>
<message> <message>
<source>Network error</source> <source>Network error</source>
<extracomment>Video playback error: network error</extracomment> <extracomment>Video playback error: network error</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished">Ошибка сети</translation>
</message> </message>
<message> <message>
<source>Access denied</source> <source>Access denied</source>
@ -533,7 +569,7 @@ This is still an alpha version :)</source>
<message> <message>
<source>Retry</source> <source>Retry</source>
<extracomment>Button to retry loading a video after a failure</extracomment> <extracomment>Button to retry loading a video after a failure</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished">Попробовать снова</translation>
</message> </message>
<message> <message>
<source>No error</source> <source>No error</source>

View file

@ -115,6 +115,19 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </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> <context>
<name>DebugPage</name> <name>DebugPage</name>
<message> <message>
@ -255,6 +268,11 @@
<source>Pull down to retry again</source> <source>Pull down to retry again</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Remote control</source>
<extracomment>Pulley menu item: shows controllable device page</extracomment>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MusicAlbumPage</name> <name>MusicAlbumPage</name>
@ -353,14 +371,6 @@ Page title for the list of all artists within the music library</extracomment>
</context> </context>
<context> <context>
<name>PlaybackBar</name> <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> <message>
<source>No audio</source> <source>No audio</source>
<translation type="unfinished"></translation> <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> <extracomment>Pulley menu item: stops playback of music</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>PosterCover</name> <name>PosterCover</name>