Skip to content

Commit

Permalink
Add Return newline on empty value Return new line if processed item…
Browse files Browse the repository at this point in the history
… value is empty
  • Loading branch information
icewolfz committed Feb 2, 2022
1 parent 7ad00e0 commit bcaccfe
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
13 changes: 13 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,10 @@
}
if (ret == null)
return true;
if (typeof ret !== 'string')
ret = ret.toString();
if (ret.length === 0 && !client.options.returnNewlineOnEmptyValue)
return true;
if (item.send) {
if (!ret.endsWith('\n'))
ret += '\n';
Expand Down Expand Up @@ -2353,6 +2357,15 @@
}, 0);
return true;
}
if (typeof ret !== 'string')
ret = ret.toString();
if (ret.length === 0 && !client.options.returnNewlineOnEmptyValue) {
setTimeout(() => {
if (client.options.CommandonClick)
client.commandInput[0].focus();
}, 0);
return true;
}
if (button.send) {
if (!ret.endsWith('\n'))
ret += '\n';
Expand Down
5 changes: 5 additions & 0 deletions build/prefs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2665,6 +2665,11 @@
</div>
<span class="help-block" style="font-size: 0.8em;margin:0;padding:0;padding-left:15px;">WARNING: Enabling profile group saving could cause sync issues and loss of data when saving preferences or profiles</span>
</div>
<div class="col-sm-6 form-group">
<label class="control-label">
<input type="checkbox" id="returnNewlineOnEmptyValue" /> Return newline on empty value
</label>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Add [Save Trigger State Changes](docs/preferences.md#advanced--profiles) Add option to control if state changes are saved every time they change
- New Advanced sub page for all profile related preferences.
- Add [Group profile saves](docs/preferences.md#advanced--profiles) and [Group profile save delay](docs/preferences.md#advanced--profiles) to allow grouping of profile saves
- Add [Return newline on empty value](docs/preferences.md#advanced--profiles) Return new line if processed item value is empty
- [Triggers](docs/profiles.md#triggers)
- Add `Loop Expression` trigger type
- Add `ReParse` and `ReParse Pattern` sub type triggers
Expand Down
2 changes: 1 addition & 1 deletion docs/preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Controls what is captured into the chat window
- `Group profile saves` Group profile saves
- **WARNING:** Enabling profile group saving could cause sync issues and loss of data when preferences saved or profile manager saves, as when saved it will flush all in memory changes and reload
- `Group profile save delay` How often between save profiles when group saves are enabled

- `Return newline on empty value` Return new line if processed item value is empty

## Advanced > Profile manager

Expand Down
9 changes: 7 additions & 2 deletions src/common/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7493,7 +7493,8 @@ export class Input extends EventEmitter {
//Convert to string
if (typeof ret !== 'string')
ret = ret.toString();

if (ret.length === 0 && !this.client.options.returnNewlineOnEmptyValue)
return null;
if (ret.endsWith('\n'))
return ret;
return ret + '\n';
Expand Down Expand Up @@ -7564,6 +7565,8 @@ export class Input extends EventEmitter {
//Convert to string
if (typeof ret !== 'string')
ret = ret.toString();
if (ret.length === 0 && !this.client.options.returnNewlineOnEmptyValue)
return null;
if (macro.send) {
if (!ret.endsWith('\n'))
ret += '\n';
Expand Down Expand Up @@ -7774,7 +7777,7 @@ export class Input extends EventEmitter {
//last check to be 100% sure enabled
if (!trigger.enabled) continue;
}
tType = this.getTriggerType(trigger.type);
tType = this.getTriggerType(trigger.type);
if (trigger.type !== undefined && (type & tType) !== tType) {
if (!subtypes || (subtypes && !this.isSubTriggerType(trigger.type)))
continue;
Expand Down Expand Up @@ -8130,6 +8133,8 @@ export class Input extends EventEmitter {
//Convert to string
if (typeof ret !== 'string')
ret = ret.toString();
if (ret.length === 0 && !this.client.options.returnNewlineOnEmptyValue)
return null;
if (!ret.endsWith('\n'))
ret += '\n';
if (this.client.connected)
Expand Down
1 change: 1 addition & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ export class Settings {
public saveTriggerStateChanges: boolean = true;
public groupProfileSaves: boolean = false;
public groupProfileSaveDelay: number = 20000;
public returnNewlineOnEmptyValue: boolean = false;

public windows = {};
public buttons = {
Expand Down

0 comments on commit bcaccfe

Please sign in to comment.