Free stroage if it is exceeding disk quota (#7061)

This commit is contained in:
Akihiko Odaki
2018-04-08 20:32:39 +09:00
committed by Eugen Rochko
parent b83ce18b30
commit 1ed1014546
6 changed files with 89 additions and 36 deletions

View File

@ -1,5 +1,5 @@
import api from '../api';
import asyncDB from '../storage/db';
import openDB from '../storage/db';
import { evictStatus } from '../storage/modifier';
import { deleteFromTimelines } from './timelines';
@ -92,12 +92,17 @@ export function fetchStatus(id) {
dispatch(fetchStatusRequest(id, skipLoading));
asyncDB.then(db => {
openDB().then(db => {
const transaction = db.transaction(['accounts', 'statuses'], 'read');
const accountIndex = transaction.objectStore('accounts').index('id');
const index = transaction.objectStore('statuses').index('id');
return getFromDB(dispatch, getState, accountIndex, index, id);
return getFromDB(dispatch, getState, accountIndex, index, id).then(() => {
db.close();
}, error => {
db.close();
throw error;
});
}).then(() => {
dispatch(fetchStatusSuccess(skipLoading));
}, () => api(getState).get(`/api/v1/statuses/${id}`).then(response => {