From 6b21befcb92e5772b12440fe96f71a85bae40068 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Fri, 23 Oct 2020 14:07:05 +0200 Subject: [PATCH] Show Server not reachable notification only once #68 --- src/common/api/rest-api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/api/rest-api.js b/src/common/api/rest-api.js index 5667ead..084456c 100644 --- a/src/common/api/rest-api.js +++ b/src/common/api/rest-api.js @@ -47,6 +47,8 @@ function isNetworkError(err) { return result; } +let prevURL = null; + class RestAPI { get(url, token) { return new Promise(function (resolve, reject) { @@ -58,7 +60,8 @@ class RestAPI { req.end(function (error, res) { if (res == null || res.status !== 200) { - error.handled = isNetworkError(error); + if (req.url !== prevURL) error.handled = isNetworkError(error); + prevURL = req.url; reject(error); } else { resolve(JSON.parse(res.text));