mirror of https://github.com/status-im/consul.git
ui: Don't cache event sources following a 401 (#11681)
This commit is contained in:
parent
f3d9565277
commit
4e0507aed3
|
@ -0,0 +1,4 @@
|
|||
```release-note:bug
|
||||
ui: Fixes an issue where under some circumstances after logging we present the
|
||||
data loaded previous to you logging in.
|
||||
```
|
|
@ -96,13 +96,15 @@ export default class DataSourceService extends Service {
|
|||
if (!(uri instanceof URI) && typeof uri !== 'string') {
|
||||
return this.unwrap(uri, ref);
|
||||
}
|
||||
runInDebug(
|
||||
_ => {
|
||||
if(!(uri instanceof URI)) {
|
||||
console.error(new Error(`DataSource '${uri}' does not use the uri helper. Please ensure you use the uri helper to ensure correct encoding`))
|
||||
}
|
||||
runInDebug(_ => {
|
||||
if (!(uri instanceof URI)) {
|
||||
console.error(
|
||||
new Error(
|
||||
`DataSource '${uri}' does not use the uri helper. Please ensure you use the uri helper to ensure correct encoding`
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
uri = uri.toString();
|
||||
let source;
|
||||
// Check the cache for an EventSource that is already being used
|
||||
|
@ -130,7 +132,11 @@ export default class DataSourceService extends Service {
|
|||
const event = source.getCurrentEvent();
|
||||
const cursor = source.configuration.cursor;
|
||||
// only cache data if we have any
|
||||
if (typeof event !== 'undefined' && typeof cursor !== 'undefined') {
|
||||
if (
|
||||
typeof event !== 'undefined' &&
|
||||
typeof cursor !== 'undefined' &&
|
||||
e.errors && e.errors[0].status !== '401'
|
||||
) {
|
||||
cache.set(uri, {
|
||||
currentEvent: event,
|
||||
cursor: cursor,
|
||||
|
|
|
@ -57,7 +57,7 @@ export default function(
|
|||
// close after the dispatch so we can tell if it was an error whilst closed or not
|
||||
// but make sure its before the promise tick
|
||||
this.readyState = 2; // CLOSE
|
||||
this.dispatchEvent({ type: 'close' });
|
||||
this.dispatchEvent({ type: 'close', error: e });
|
||||
})
|
||||
.then(() => {
|
||||
// This only gets called when the promise chain completely finishes
|
||||
|
|
Loading…
Reference in New Issue