ui: Don't cache event sources following a 401 (#11681)
This commit is contained in:
parent
c6dd21f4dd
commit
33a405ae8f
|
@ -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') {
|
if (!(uri instanceof URI) && typeof uri !== 'string') {
|
||||||
return this.unwrap(uri, ref);
|
return this.unwrap(uri, ref);
|
||||||
}
|
}
|
||||||
runInDebug(
|
runInDebug(_ => {
|
||||||
_ => {
|
|
||||||
if (!(uri instanceof URI)) {
|
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`))
|
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();
|
uri = uri.toString();
|
||||||
let source;
|
let source;
|
||||||
// Check the cache for an EventSource that is already being used
|
// 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 event = source.getCurrentEvent();
|
||||||
const cursor = source.configuration.cursor;
|
const cursor = source.configuration.cursor;
|
||||||
// only cache data if we have any
|
// 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, {
|
cache.set(uri, {
|
||||||
currentEvent: event,
|
currentEvent: event,
|
||||||
cursor: cursor,
|
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
|
// 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
|
// but make sure its before the promise tick
|
||||||
this.readyState = 2; // CLOSE
|
this.readyState = 2; // CLOSE
|
||||||
this.dispatchEvent({ type: 'close' });
|
this.dispatchEvent({ type: 'close', error: e });
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// This only gets called when the promise chain completely finishes
|
// This only gets called when the promise chain completely finishes
|
||||||
|
|
Loading…
Reference in New Issue