mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
UX: On first load of notifications don't use cached data
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
import StaleResult from 'discourse/lib/stale-result';
|
import StaleResult from 'discourse/lib/stale-result';
|
||||||
import { hashString } from 'discourse/lib/hash';
|
import { hashString } from 'discourse/lib/hash';
|
||||||
|
|
||||||
|
var skipFirst = true;
|
||||||
|
|
||||||
// Mix this in to an adapter to provide stale caching in our key value store
|
// Mix this in to an adapter to provide stale caching in our key value store
|
||||||
export default {
|
export default {
|
||||||
storageKey(type, findArgs) {
|
storageKey(type, findArgs) {
|
||||||
@ -11,10 +13,14 @@ export default {
|
|||||||
findStale(store, type, findArgs) {
|
findStale(store, type, findArgs) {
|
||||||
const staleResult = new StaleResult();
|
const staleResult = new StaleResult();
|
||||||
try {
|
try {
|
||||||
const stored = this.keyValueStore.getItem(this.storageKey(type, findArgs));
|
if (!skipFirst) {
|
||||||
if (stored) {
|
const stored = this.keyValueStore.getItem(this.storageKey(type, findArgs));
|
||||||
const parsed = JSON.parse(stored);
|
if (stored) {
|
||||||
staleResult.setResults(parsed);
|
const parsed = JSON.parse(stored);
|
||||||
|
staleResult.setResults(parsed);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
skipFirst = false;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// JSON parsing error
|
// JSON parsing error
|
||||||
|
Reference in New Issue
Block a user