1
Fork 0
- Fixed issue that prevented favorites toggle to switch on on the Photos page
- The favorites toggle is moved on left
This commit is contained in:
stz184 2020-09-26 02:18:30 +03:00
parent 9212ac52eb
commit 85a8dbedb0
3 changed files with 21 additions and 22 deletions

View File

@ -52,21 +52,21 @@ function AlbumPage({ match }) {
) )
const toggleFavorites = refetch => { const toggleFavorites = refetch => {
const onlyFavorites = !onlyFavorites const newState = !onlyFavorites
if ( if (
(refetchNeededAll && !onlyFavorites) || (refetchNeededAll && !newState) ||
(refetchNeededFavorites && onlyFavorites) (refetchNeededFavorites && newState)
) { ) {
refetch({ id: albumId, onlyFavorites: onlyFavorites }).then(() => { refetch({ id: albumId, onlyFavorites: newState }).then(() => {
if (onlyFavorites) { if (onlyFavorites) {
refetchNeededFavorites = false refetchNeededFavorites = false
} else { } else {
refetchNeededAll = false refetchNeededAll = false
} }
setOnlyFavorites(onlyFavorites) setOnlyFavorites(newState)
}) })
} else { } else {
setOnlyFavorites(onlyFavorites) setOnlyFavorites(newState)
} }
history.replaceState( history.replaceState(
{}, {},

View File

@ -44,8 +44,7 @@ const photoQuery = gql`
` `
const FavoritesCheckbox = styled(Checkbox)` const FavoritesCheckbox = styled(Checkbox)`
float: right; margin: 0.5rem 0 0 0;
margin: 0.5rem 0 0 1rem;
` `
class PhotosPage extends Component { class PhotosPage extends Component {

View File

@ -34,9 +34,7 @@ const StyledIcon = styled(Icon)`
` `
const FavoritesCheckbox = styled(Checkbox)` const FavoritesCheckbox = styled(Checkbox)`
float: right; margin-bottom: 16px;
padding-left: 10px;
margin-top: 0.5rem;
` `
const SettingsIcon = props => { const SettingsIcon = props => {
@ -103,6 +101,7 @@ const AlbumTitle = ({
} }
return ( return (
<>
<Header> <Header>
<Breadcrumb>{breadcrumbSections}</Breadcrumb> <Breadcrumb>{breadcrumbSections}</Breadcrumb>
{title} {title}
@ -113,6 +112,7 @@ const AlbumTitle = ({
}} }}
/> />
)} )}
</Header>
{authToken() && showFavoritesToggle && ( {authToken() && showFavoritesToggle && (
<FavoritesCheckbox <FavoritesCheckbox
toggle toggle
@ -122,7 +122,7 @@ const AlbumTitle = ({
onChange={setOnlyFavorites} onChange={setOnlyFavorites}
/> />
)} )}
</Header> </>
) )
} }