Skip to content

Commit

Permalink
removed hardcoded share limit #451
Browse files Browse the repository at this point in the history
  • Loading branch information
io53 committed Oct 21, 2024
1 parent 26681cb commit 3beab8f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"alertDescriptionMaxLength": 100,
"dataFetchPaginationSize": 1500,
"dataCacheLengthInDays": 730,
"maxSharesPerSensor": 10,
"uploadImageMaxSize": 3000
},
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ShareDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ShareDialog extends Component {
this.setState({ ...this.state, email: evt.target.value });
}
isInvalidValid = () => {
return this.state.loading || this.props.sensor.sharedTo.length >= pjson.settings.maxSharesPerSensor || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.state.email)
return this.state.loading || this.props.sensor.sharedTo.length >= this.props.sensor.subscription.maxSharesPerSensor || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.state.email)
}
keyDown = (e) => {
if (e.key === 'Enter') {
Expand All @@ -96,7 +96,7 @@ class ShareDialog extends Component {
<Button disabled={this.isInvalidValid()} onClick={this.share.bind(this)} mt="17px">{t("share")}</Button>
</div>
{this.props.sensor.sharedTo.length > 0 && <>
<div style={{ fontWeight: "bold", marginTop: 8, marginBottom: 8 }}>{addVariablesInString(t("share_sensor_already_shared"), [this.props.sensor.sharedTo.length, pjson.settings.maxSharesPerSensor])}</div>
<div style={{ fontWeight: "bold", marginTop: 8, marginBottom: 8 }}>{addVariablesInString(t("share_sensor_already_shared"), [this.props.sensor.sharedTo.length, this.props.sensor.subscription.maxSharesPerSensor])}</div>
<List spacing={3}>
{this.props.sensor.sharedTo.map(x => {
return <ListItem key={x}>
Expand Down
2 changes: 1 addition & 1 deletion src/states/Sensor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class Sensor extends Component {
{t("share")}
</td>
<td style={detailedText}>
{addVariablesInString(t("shared_to_x"), [this.props.sensor.sharedTo.length, pjson.settings.maxSharesPerSensor])}
{addVariablesInString(t("shared_to_x"), [this.props.sensor.sharedTo.length, this.props.sensor.subscription.maxSharesPerSensor])}
<IconButton variant="ghost" icon={<MdChevronRight />} _hover={{}} />
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions src/states/ShareCenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const SensorsSharedByMeBox = (props) => {
{props.sensor.name || props.sensor.sensor}
</div>
<div style={{ fontFamily: "mulish", paddingBottom: 4, fontSize: 14 }}>
{i18next.t("active_shares")} ({props.sensor.sharedTo.length}/{pjson.settings.maxSharesPerSensor})
{i18next.t("active_shares")} ({props.sensor.sharedTo.length}/{props.sensor.subscription.maxSharesPerSensor})
</div>
<Flex gap='2' wrap="wrap" >
{props.sensor.sharedTo.map((sharedWith, index) => (
Expand Down Expand Up @@ -128,7 +128,7 @@ const ShareCenter = () => {
}

let mySensors = sensors.filter(x => x.userIsOwner)
let sensorsThatCanBeShared = mySensors.filter(x => x.sharedTo.length < pjson.settings.maxSharesPerSensor)
let sensorsThatCanBeShared = mySensors.filter(x => x.sharedTo.length < x.subscription.maxSharesPerSensor)
sensorsThatCanBeShared = sensorsThatCanBeShared.filter(sensor => !selectedSensors.includes(sensor.sensor));

const selectSensorTitle = <div style={{ marginTop: 8, paddingRight: 8, fontWeight: 800, fontFamily: "mulish" }}>{i18next.t("sensors_select_label")}</div>
Expand Down

0 comments on commit 3beab8f

Please sign in to comment.