Skip to content

Commit

Permalink
unique history per app
Browse files Browse the repository at this point in the history
  • Loading branch information
iMac7 committed May 19, 2024
1 parent 571d8f6 commit 85a2856
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/dashboard/Data/Config/Config.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,26 @@ class Config extends TableView {
.then(
() => {
this.setState({ modalOpen: false });
const limit = this.context.historylimit;
const limit = this.context.cloudConfigHistoryLimit;
const applicationId = this.context.applicationId;
let transformedValue = value;
if(type === 'Date') {
transformedValue = {__type: 'Date', iso: value};
}
if(type === 'File') {
transformedValue = {name: value._name, url: value._url};
}
const configHistory = localStorage.getItem('configHistory');
const configHistory = localStorage.getItem(`${applicationId}_configHistory`);
if(!configHistory) {
localStorage.setItem('configHistory', JSON.stringify({
localStorage.setItem(`${applicationId}_configHistory`, JSON.stringify({
[name]: [{
time: new Date(),
value: transformedValue
}]
}));
} else {
const oldConfigHistory = JSON.parse(configHistory);
localStorage.setItem('configHistory', JSON.stringify({
localStorage.setItem(`${applicationId}_configHistory`, JSON.stringify({
...oldConfigHistory,
[name]: !oldConfigHistory[name] ?
[{time: new Date(), value: transformedValue}]
Expand Down
4 changes: 3 additions & 1 deletion src/dashboard/Data/Config/ConfigDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import validateNumeric from 'lib/validateNumeric';
import styles from 'dashboard/Data/Browser/Browser.scss';
import semver from 'semver/preload.js';
import { dateStringUTC } from 'lib/DateUtils';
import { CurrentApp } from 'context/currentApp';

const PARAM_TYPES = ['Boolean', 'String', 'Number', 'Date', 'Object', 'Array', 'GeoPoint', 'File'];

Expand Down Expand Up @@ -91,6 +92,7 @@ const GET_VALUE = {
};

export default class ConfigDialog extends React.Component {
static contextType = CurrentApp;
constructor(props) {
super();
this.state = {
Expand Down Expand Up @@ -194,7 +196,7 @@ export default class ConfigDialog extends React.Component {
))}
</Dropdown>
);
const configHistory = localStorage.getItem('configHistory') && JSON.parse(localStorage.getItem('configHistory'))[this.state.name];
const configHistory = localStorage.getItem(`${this.context.applicationId}_configHistory`) && JSON.parse(localStorage.getItem(`${this.context.applicationId}_configHistory`))[this.state.name];
const handleIndexChange = index => {
if(this.state.type === 'Date'){
return;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ParseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class ParseApp {
scripts,
classPreference,
enableSecurityChecks,
historylimit
cloudConfigHistoryLimit
}) {
this.name = appName;
this.createdAt = created_at ? new Date(created_at) : new Date();
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class ParseApp {
this.columnPreference = columnPreference;
this.scripts = scripts;
this.enableSecurityChecks = !!enableSecurityChecks;
this.historylimit = historylimit;
this.cloudConfigHistoryLimit = cloudConfigHistoryLimit;

if (!supportedPushLocales) {
console.warn(
Expand Down

0 comments on commit 85a2856

Please sign in to comment.