Skip to content

Commit

Permalink
dunzo
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhartigan committed Mar 23, 2022
1 parent 79c2e20 commit bdc5ae3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/components/collection/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function Collection(props) {
{!smallWindow ?
(
<>
<SkinChangerWarning skinsOwned={props.skinsOwned}/>
{props.loadout !== null ? <SkinChangerWarning skinsOwned={props.skinsOwned}/> : null}
<Grid className={classes.root} style={props.style} container justifyContent="center" direction="row" alignItems="center" spacing={3}>
{grid.map(row => {
if (props.loadout !== null) {
Expand Down
23 changes: 18 additions & 5 deletions client/src/components/collection/sub/SkinChangerWarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,36 @@ function SkinChangerWarning(props){
const skinsOwned = props.skinsOwned

const [acknowledged, setAcknowledged] = useLocalStorage("skinChangerWarningAcknowledged", false);
const [enableButton, setEnableButton] = useState(false);
const [open, setOpen] = useState(false);

useEffect(() => {
if(skinsOwned > Config.SKIN_CHANGER_WARNING_THRESHOLD){
if(skinsOwned > Config.SKIN_CHANGER_WARNING_THRESHOLD && skinsOwned !== -1){
setAcknowledged(true);
}
})
if((!acknowledged && skinsOwned < Config.SKIN_CHANGER_WARNING_THRESHOLD) && skinsOwned !== -1){
setOpen(true);
}
}, [skinsOwned]);

useEffect(() => {
if(open){
setTimeout(() => {
setEnableButton(true);
}, 3000);
}
}, [open])

return (
<Dialog open={!acknowledged && skinsOwned < Config.SKIN_CHANGER_WARNING_THRESHOLD} fullWidth maxWidth="xs" onClose={null}>
<DialogTitle>VIM is NOT a skin changer</DialogTitle>
<Dialog open={open} fullWidth maxWidth="xs" onClose={null}>
<DialogTitle>⚠️ VIM is NOT a skin changer ⚠️</DialogTitle>
<DialogContent className={classes.content}>
<DialogContentText style={{ }}>
You own {skinsOwned} skins. VIM is NOT a skin changer and will not give you "free skins". VIM only works with skins you own.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button color="primary" onClick={() => {setAcknowledged(true)}}>
<Button disabled={!enableButton} color="primary" onClick={() => {setAcknowledged(true); setOpen(false);}}>
I understand
</Button>
</DialogActions>
Expand Down
9 changes: 6 additions & 3 deletions client/src/pages/CollectionHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function CollectionHome(props) {
const [showWeaponEditor, setWeaponEditorState] = useState(false);
const [loadout, setLoadout] = useState({});
const [weaponEditor, setWeaponEditor] = useState();
const [uniqueSkinsOwned, setUniqueSkinsOwned] = useState(0);
const [uniqueSkinsOwned, setUniqueSkinsOwned] = useState(-1);

useEffect(() => {
if (!loaded) {
Expand All @@ -51,12 +51,15 @@ function CollectionHome(props) {

useEffect(() => {
// count how many skins are owned for skin changer warning dialog
var skinsOwned = 0;
var skinsOwned = -1;

for (var weapon in inventoryData) {
skinsOwned += Object.keys(inventoryData[weapon].skins).length - 1;
}
setUniqueSkinsOwned(skinsOwned);
if(skinsOwned !== -1){
setUniqueSkinsOwned(skinsOwned + 1);
}

}, [inventoryData])

function load() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/services/ClientConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Config = {
SOCKET_RETRY_THRESHOLD: 5,

WEIGHT_INTERVALS: 10,
SKIN_CHANGER_WARNING_THRESHOLD: 5,
SKIN_CHANGER_WARNING_THRESHOLD: 10,

NAVIGATION_ENABLED: false,
ENABLED_PAGES: {
Expand Down

0 comments on commit bdc5ae3

Please sign in to comment.