Skip to content

Commit 7c62552

Browse files
authored
Merge pull request #6 from 9yz/5-error-running-the-plugin
Reworked versioning in preferences; fixed bug with prefs loading
2 parents 05e5d58 + 6e0a513 commit 7c62552

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

textSubstitutions.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const TS_DELIMITERS = [
2121
["=", "=", 1],
2222
["==", "==", 2],
2323
]
24-
const TS_VERSION = "1.0";
24+
const TS_VERSION = "1.0.1";
25+
const TS_VERSION_PREFS = 100001; // equal to 1.000.01, or 1.0.1
2526

2627
var TS_SUB_TABLE_BUILTIN;
2728
var TS_SUB_TABLE_USER;
@@ -379,19 +380,24 @@ function tsPrefsPanel(){
379380
}
380381

381382
// reset prefs to defaults
382-
function tsSetDefaultPrefs(){
383-
app.preferences.tsDelimiter = 1; // int representing the `delimiters` array index of the delimiter to use
384-
app.preferences.tsDateField = 0; // 0 = EXIF, 1 = IPTC
385-
app.preferences.tsSeparateTags = 0; // 1 = seperate tags
386-
app.preferences.tsRecursionLimit = 100; // max number of recursions before error
387-
app,preferences.tsPrefsVersion = TS_VERSION;
383+
// if allPrefs = true, all prefs are set (optional)
384+
function tsSetDefaultPrefs(allPrefs){
385+
if(!allPrefs) allPrefs = false; // set to false if not specified
386+
if(allPrefs || app.preferences.tsPrefsVersion < TS_VERSION_PREFS){ // ver 100001
387+
app.preferences.tsDelimiter = 1; // int representing the `delimiters` array index of the delimiter to use
388+
app.preferences.tsDateField = 0; // 0 = EXIF, 1 = IPTC
389+
app.preferences.tsSeparateTags = 0; // 1 = seperate tags
390+
app.preferences.tsRecursionLimit = 100; // max number of recursions before error
391+
}
392+
app.preferences.tsPrefsVersion = TS_VERSION_PREFS;
388393
app.preferences.tsPrefsSet = true;
389394
}
390395

391396
// set vars based on prefs
392397
function tsInitalizePrefs(){
393398
// set default prefs if they havent been set
394-
if(app.preferences.tsPrefsSet != true) tsSetDefaultPrefs();
399+
if(app.preferences.tsPrefsSet != true) tsSetDefaultPrefs(true); // first run
400+
else if(app.preferences.tsPrefsVersion < TS_VERSION_PREFS) tsSetDefaultPrefs(); // upgrading
395401

396402
tsInitalizePrefsDelimiter();
397403
}

0 commit comments

Comments
 (0)