mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix account list and remove sanctum
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
import {api} from "../../../../boot/axios";
|
||||
import format from "date-fns/format";
|
||||
import {getCacheKey} from "../../../../support/get-cache-key.js";
|
||||
|
||||
export default class Get {
|
||||
|
||||
@@ -37,6 +38,31 @@ export default class Get {
|
||||
return api.get('/api/v1/accounts/' + identifier, {params: params});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @returns {Promise<AxiosResponse<any>>}
|
||||
*/
|
||||
index(params) {
|
||||
// first, check API in some consistent manner.
|
||||
// then, load if necessary.
|
||||
const cacheKey = getCacheKey('/api/v1/accounts', params);
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
|
||||
if (cacheValid && typeof cachedData !== 'undefined') {
|
||||
console.log('Cache is valid, return cache.');
|
||||
return Promise.resolve(cachedData);
|
||||
}
|
||||
|
||||
// if not, store in cache and then return res.
|
||||
|
||||
return api.get('/api/v1/accounts', {params: params}).then(response => {
|
||||
console.log('Cache is invalid, return fresh.');
|
||||
window.store.set(cacheKey, response.data);
|
||||
return Promise.resolve({data: response.data.data, meta: response.data.meta});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -383,7 +383,8 @@ let index = function () {
|
||||
// one page only.o
|
||||
(new Get()).index(params).then(response => {
|
||||
console.log(response);
|
||||
this.totalPages = response.meta.lastPage;
|
||||
this.totalPages = response.meta.pagination.total_pages;
|
||||
console.log('a');
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
if (response.data.hasOwnProperty(i)) {
|
||||
let current = response.data[i];
|
||||
|
Reference in New Issue
Block a user