Resetting everything, then restoringg essentials, fixes #734; Buildout ago
This commit is contained in:
@ -22,6 +22,7 @@ import * as spotifyActions from '../services/spotify/actions';
|
||||
import { isHosted } from '../util/helpers';
|
||||
import { i18n, I18n, languagesAvailable } from '../locale';
|
||||
import Button from '../components/Button';
|
||||
import { dater } from '../components/Dater';
|
||||
|
||||
const CheckboxSetting = ({
|
||||
name,
|
||||
@ -461,8 +462,13 @@ class Settings extends React.Component {
|
||||
{pusher.version.current}
|
||||
</a>
|
||||
{' '}
|
||||
<span className="mid_grey-text">
|
||||
<span className="mid_grey-text tooltip">
|
||||
{build}
|
||||
{build && (
|
||||
<span className="tooltip__content">
|
||||
{dater('ago', parseInt(build, 10) * 1000)} ago
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{pusher.version.upgrade_available ? (
|
||||
<a
|
||||
|
||||
@ -22,7 +22,8 @@ import { sourceIcon } from '../util/helpers';
|
||||
import { i18n, I18n } from '../locale';
|
||||
import Button from '../components/Button';
|
||||
import { makeLoadingSelector, makeItemSelector } from '../util/selectors';
|
||||
import { decodeUri } from '../util/format';
|
||||
import { decodeUri, encodeUri } from '../util/format';
|
||||
import URILink from '../components/URILink';
|
||||
|
||||
const LyricsSelector = ({
|
||||
track: {
|
||||
@ -258,7 +259,7 @@ class Track extends React.Component {
|
||||
|
||||
<h1>{track.name}</h1>
|
||||
<h2>
|
||||
{track.album && track.album.uri && <Link to={`/album/${track.album.uri}`}>{track.album.name}</Link>}
|
||||
{track?.album?.uri && <URILink uri={track.album.uri} type="album">{track.album.name}</URILink>}
|
||||
{track.album && !track.album.uri ? track.album.name : null}
|
||||
{!track.album && <I18n path="track.unknown_album" />}
|
||||
<I18n path="common.by" />
|
||||
|
||||
@ -72,19 +72,27 @@ class Reset extends React.Component {
|
||||
if (database) {
|
||||
tasks.push(
|
||||
new Promise((resolve) => {
|
||||
localForage.keys().then((keys) => {
|
||||
const keysToRemove = keys.filter(
|
||||
(key) => !stateKeys.includes(key.replace('persist:', '')),
|
||||
);
|
||||
keysToRemove.forEach((key, index) => {
|
||||
localForage.removeItem(key).then(() => {
|
||||
console.debug(`Removed ${key}`);
|
||||
if (index === keysToRemove.length - 1) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
// Fetch all our core keys and store them in memory while we wipe the whole database,
|
||||
// then we restore them back. This is much faster than checking keys and deleting items
|
||||
// one-by-one
|
||||
Promise.all(
|
||||
stateKeys.map((key) => localForage.getItem(`persist:${key}`)),
|
||||
).then(
|
||||
(items) => {
|
||||
localForage.clear().then(
|
||||
() => {
|
||||
console.debug({ items });
|
||||
Promise.all(
|
||||
items.map(
|
||||
(item, index) => localForage.setItem(`persist:${stateKeys[index]}`, item),
|
||||
),
|
||||
).then(
|
||||
() => resolve(),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user