fixes
This commit is contained in:
@@ -40,7 +40,6 @@ class Document extends BaseModel {
|
||||
views: number;
|
||||
|
||||
data: Object;
|
||||
fetchedAt: Date;
|
||||
|
||||
/* Computed */
|
||||
|
||||
@@ -102,10 +101,6 @@ class Document extends BaseModel {
|
||||
: null;
|
||||
}
|
||||
|
||||
get timeSinceFetch(): number {
|
||||
return (new Date() - this.fetchedAt) / 1000;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
|
||||
@action star = async () => {
|
||||
@@ -250,7 +245,6 @@ class Document extends BaseModel {
|
||||
if (dirty) this.hasPendingChanges = true;
|
||||
this.data = data;
|
||||
extendObservable(this, data);
|
||||
this.fetchedAt = new Date();
|
||||
}
|
||||
|
||||
constructor(data?: Object = {}) {
|
||||
|
||||
@@ -116,11 +116,6 @@ class DocumentsStore extends BaseStore {
|
||||
};
|
||||
|
||||
@action fetch = async (id: string, prefetch?: boolean): Promise<*> => {
|
||||
/** If document has been fetched under 5s ago, return it */
|
||||
const existingDocument = this.getById(id);
|
||||
if (existingDocument && existingDocument.timeSinceFetch < 5)
|
||||
return existingDocument;
|
||||
|
||||
if (!prefetch) this.isFetching = true;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user