Skip to content

Commit 923643a

Browse files
committed
update settings.registerPluginSettings to support a seperate display and id keys
1 parent 022d837 commit 923643a

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

src/animatedJava.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import { intl } from './util/intl'
1919
import { CustomError } from './util/customError'
2020

2121
const errorMessages = [
22-
"Uh oh!",
22+
'Uh oh!',
2323
"Time to fire up the ol' debugger!",
24-
"Your armor stands are sad :(",
25-
"Ok, who pushed the big red button?",
24+
'Your armor stands are sad :(',
25+
'Ok, who pushed the big red button?',
2626
]
2727

2828
function getRandomErrorMessage() {
29-
const index = Math.round(Math.random() * (errorMessages.length-1))
29+
const index = Math.round(Math.random() * (errorMessages.length - 1))
3030
return errorMessages[index]
3131
}
3232

@@ -42,14 +42,20 @@ function showUnknownErrorDialog(e: CustomError | any) {
4242
id: 'animatedJava.dialogs.miscError',
4343
title: tl('animatedJava.dialogs.errors.misc.title'),
4444
lines: [
45-
tl('animatedJava.dialogs.errors.misc.body', {
46-
buildID: process.env.BUILD_ID,
47-
errorMessage: e.options ? e.options.message : e.message,
48-
randomErrorMessage: getRandomErrorMessage(),
49-
errorStack: e.stack,
50-
discordLink: process.env.DISCORD_LINK,
51-
githubLink: process.env.GITHUB_ISSUES_LINK,
52-
}, true),
45+
tl(
46+
'animatedJava.dialogs.errors.misc.body',
47+
{
48+
buildID: process.env.BUILD_ID,
49+
errorMessage: e.options
50+
? e.options.message
51+
: e.message,
52+
randomErrorMessage: getRandomErrorMessage(),
53+
errorStack: e.stack,
54+
discordLink: process.env.DISCORD_LINK,
55+
githubLink: process.env.GITHUB_ISSUES_LINK,
56+
},
57+
true
58+
),
5359
],
5460
width: 1024,
5561
height: 512,

src/settings.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { tl } from './util/intl'
1010
const genericEmptyErrorText = tl(
1111
'animatedJava.settings.generic.errors.emptyValue'
1212
)
13-
13+
export let ForeignSettingTranslationKeys = {}
1414
const UNASSIGNED = Symbol('UNASSIGNED_CACHE')
1515
export const DefaultSettings = {
1616
animatedJava: {
@@ -522,15 +522,16 @@ class Settings {
522522
return res
523523
}
524524

525-
registerPluginSettings(pluginName, settings) {
526-
DefaultSettings[pluginName] = settings
525+
registerPluginSettings(exporterId, exporterSettingsKey, settings) {
526+
DefaultSettings[exporterSettingsKey] = settings
527+
ForeignSettingTranslationKeys[exporterSettingsKey] = exporterId
527528
this.update(
528529
{
529-
[pluginName]: settings,
530+
[exporterSettingsKey]: settings,
530531
},
531532
true
532533
)
533-
this.assign(pluginName, Object.keys(settings))
534+
this.assign(exporterSettingsKey, Object.keys(settings))
534535
}
535536

536537
toConsumable(target = 'all') {

src/ui/dialogs/settings.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { bus } from '../../util/bus'
22
import events from '../../constants/events'
33
import React, { useEffect, useRef, useState } from 'react'
44
import ReactDom from 'react-dom'
5-
import { DefaultSettings, settings } from '../../settings'
5+
import {
6+
DefaultSettings,
7+
ForeignSettingTranslationKeys,
8+
settings,
9+
} from '../../settings'
610
import { tl } from '../../util/intl'
711
import { ERROR } from '../../util/errors'
812
const dialog = electron.dialog
@@ -462,7 +466,12 @@ const Settings = () => {
462466
// SettingsPanel(key, setRevealedIndex, index, revealedIndex, children)
463467
<SettingsPanel
464468
key={key}
465-
name={key}
469+
name={
470+
ForeignSettingTranslationKeys[
471+
key
472+
] || key
473+
}
474+
id={key}
466475
childrenSettings={children}
467476
/>
468477
)
@@ -476,17 +485,17 @@ const Settings = () => {
476485
)
477486
}
478487

479-
function SettingsPanel({ childrenSettings, name, visible }) {
488+
function SettingsPanel({ childrenSettings, name, visible, id }) {
480489
const [shown, setShown] = useState(visible)
481490
return (
482491
<DropDown visible={shown} onClick={() => setShown(!shown)} name={name}>
483492
<ul style={{ marginLeft: '2em' }}>
484-
{childrenSettings.map((child, id) => (
493+
{childrenSettings.map((child) => (
485494
<li key={child}>
486495
<SettingInput
487-
namespace={name}
496+
namespace={id}
488497
name={child}
489-
template={DefaultSettings[name][child]}
498+
template={DefaultSettings[id][child]}
490499
></SettingInput>
491500
</li>
492501
))}

0 commit comments

Comments
 (0)