Free stroage if it is exceeding disk quota (#7061)
This commit is contained in:
committed by
Eugen Rochko
parent
b83ce18b30
commit
1ed1014546
@ -1,5 +1,5 @@
|
||||
import api, { getLinks } from '../api';
|
||||
import asyncDB from '../storage/db';
|
||||
import openDB from '../storage/db';
|
||||
import { importAccount, importFetchedAccount, importFetchedAccounts } from './importer';
|
||||
|
||||
export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
|
||||
@ -94,12 +94,15 @@ export function fetchAccount(id) {
|
||||
|
||||
dispatch(fetchAccountRequest(id));
|
||||
|
||||
asyncDB.then(db => getFromDB(
|
||||
openDB().then(db => getFromDB(
|
||||
dispatch,
|
||||
getState,
|
||||
db.transaction('accounts', 'read').objectStore('accounts').index('id'),
|
||||
id
|
||||
)).catch(() => api(getState).get(`/api/v1/accounts/${id}`).then(response => {
|
||||
).then(() => db.close(), error => {
|
||||
db.close();
|
||||
throw error;
|
||||
})).catch(() => api(getState).get(`/api/v1/accounts/${id}`).then(response => {
|
||||
dispatch(importFetchedAccount(response.data));
|
||||
})).then(() => {
|
||||
dispatch(fetchAccountSuccess());
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { autoPlayGif } from '../../initial_state';
|
||||
import { putAccounts, putStatuses } from '../../storage/modifier';
|
||||
import { normalizeAccount, normalizeStatus } from './normalizer';
|
||||
|
||||
@ -44,7 +45,7 @@ export function importFetchedAccounts(accounts) {
|
||||
}
|
||||
|
||||
accounts.forEach(processAccount);
|
||||
putAccounts(normalAccounts);
|
||||
putAccounts(normalAccounts, !autoPlayGif);
|
||||
|
||||
return importAccounts(normalAccounts);
|
||||
}
|
||||
|
@ -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 => {
|
||||
|
Reference in New Issue
Block a user