This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/scenes/Dashboard/DashboardStore.js
2016-08-05 18:09:14 +03:00

31 lines
800 B
JavaScript

import { observable, action, runInAction } from 'mobx';
import { client, cacheResponse } from 'utils/ApiClient';
const store = new class DashboardStore {
@observable collections;
@observable pagination;
@observable isFetching = true;
/* Actions */
@action fetchCollections = async (teamId) => {
this.isFetching = true;
try {
const res = await client.post('/collections.list', { id: teamId });
const { data, pagination } = res;
runInAction('fetchCollections', () => {
this.collections = data;
this.pagination = pagination;
data.forEach((collection) => cacheResponse(collection.recentDocuments));
});
} catch (e) {
console.error("Something went wrong");
}
this.isFetching = false;
}
}();
export default store;