summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-04-23 20:19:47 +0200
committerJulius Härtl <jus@bitgrid.net>2020-04-23 20:19:47 +0200
commita143e3663002625e54f334a908c8b8c13977b3fd (patch)
tree12ba99c0ccc8ac586d15df7c5048dd190153da34
parent2eadf9d567379e04a0dd8b483e6fe7e3e926716b (diff)
downloadnextcloud-server-a143e3663002625e54f334a908c8b8c13977b3fd.tar.gz
nextcloud-server-a143e3663002625e54f334a908c8b8c13977b3fd.zip
Make sure that the legacy jsunit tests can still inject OC.config
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--core/src/session-heartbeat.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/core/src/session-heartbeat.js b/core/src/session-heartbeat.js
index cf358bc35a1..9c9148d2c77 100644
--- a/core/src/session-heartbeat.js
+++ b/core/src/session-heartbeat.js
@@ -28,12 +28,18 @@ import { generateUrl } from './OC/routing'
import OC from './OC'
import { setToken as setRequestToken, getToken as getRequestToken } from './OC/requesttoken'
-let config
-try {
- config = loadState('core', 'config')
-} catch (e) {
- // This fallback is just for our legacy jsunit tests since we have no way to mock loadState calls
- config = OC.config
+let config = null
+/**
+ * The legacy jsunit tests overwrite OC.config before calling initCore
+ * therefore we need to wait with assigning the config fallback until initCore calls initSessionHeartBeat
+ */
+const loadConfig = () => {
+ try {
+ config = loadState('core', 'config')
+ } catch (e) {
+ // This fallback is just for our legacy jsunit tests since we have no way to mock loadState calls
+ config = OC.config
+ }
}
/**
@@ -131,6 +137,8 @@ const registerAutoLogout = () => {
* token doesn't expire
*/
export const initSessionHeartBeat = () => {
+ loadConfig()
+
registerAutoLogout()
if (!keepSessionAlive()) {