Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Oct 15, 2021
1 parent 3b004d0 commit be79dec
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
23 changes: 5 additions & 18 deletions src/components/common/PinButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,26 @@ const PinButton = ({ item }) => {
const [isPinned, setPinned] = useState(item?.settings?.isPinned);

const handlePin = () => {
const { settings } = item;
settings.isPinned = true;
const newState = !isPinned;

editItem.mutate({
id: item.id,
// use item login tag id
name: item.name,
settings: item.settings,
});

setPinned(true);
};
setPinned(newState);

const handleUnpin = () => {
const { settings } = item;
settings.isPinned = false;
settings.isPinned = newState;

editItem.mutate({
id: item.id,
// use item login tag id
name: item.name,
settings: item.settings,
});

setPinned(false);
};

return (
<Tooltip title={isPinned ? t('Unpin') : t('Pin')}>
<IconButton
aria-label="favorite"
aria-label={isPinned ? t('Unpin') : t('Pin')}
className={PIN_ITEM_BUTTON_CLASS}
onClick={isPinned ? handleUnpin : handlePin}
onClick={handlePin}
>
{isPinned ? (
<PushPinIcon fontSize="small" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/settings/ItemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ItemSettings = ({ item }) => {

<FormGroup>
<FormControlLabel
label="Pin Item"
label={t('Pin')}
control={(
<Switch
id={SETTINGS_PINNED_TOGGLE}
Expand All @@ -76,7 +76,7 @@ const ItemSettings = ({ item }) => {
)}
/>
<FormControlLabel
label="Show Chatbox"
label={t('Show Chat')}
control={(
<Switch
id={SETTINGS_CHATBOX_TOGGLE}
Expand Down
3 changes: 1 addition & 2 deletions src/components/main/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { withRouter } from 'react-router';
import { List } from 'immutable';
import { hooks } from '../../config/queryClient';
import ItemHeader from '../item/header/ItemHeader';
import Items from './Items';
Expand Down Expand Up @@ -33,7 +32,7 @@ const Home = () => {
<Items
id={OWNED_ITEMS_ID}
title={t('My Items')}
items={List(ownItems)}
items={ownItems}
headerElements={[<NewItemButton fontSize="small" />]}
/>
</Main>
Expand Down
5 changes: 4 additions & 1 deletion src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"Authenticated Members": "Authenticated Members",
"Username and Password": "Username and Password",
"Username": "Username",
"No user has authenticated to this item yet.": "No user has authenticated to this item yet."
"No user has authenticated to this item yet.": "No user has authenticated to this item yet.",
"Pin": "Pin this item",
"Unpin": "Unpin this item",
"Show Chat": "Show Chat"
}
}
5 changes: 4 additions & 1 deletion src/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"Authenticated Members": "Membres Connectés",
"Username and Password": "Nom d'utilisateur et Mot de passe",
"Username": "Nom d'utilisateur",
"No user has authenticated to this item yet.": "Aucun utilisateur ne s'est encore connecté à cet élément."
"No user has authenticated to this item yet.": "Aucun utilisateur ne s'est encore connecté à cet élément.",
"Pin": "Epingler cet élément",
"Unpin": "Détacher cet élément",
"Show Chat": "Afficher le chat"
}
}

0 comments on commit be79dec

Please sign in to comment.