Fix registering unamed settings
This commit is contained in:
parent
6d12f018cd
commit
c5de5ef1d0
3 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,16 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
label: 'Unnamed 1',
|
||||||
|
type: 'input'
|
||||||
|
})
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
label: 'Unnamed 2',
|
||||||
|
type: 'input'
|
||||||
|
})
|
||||||
|
|
||||||
const actionHooks = [
|
const actionHooks = [
|
||||||
'action:application.listening',
|
'action:application.listening',
|
||||||
'action:notifier.notification.created',
|
'action:notifier.notification.created',
|
||||||
|
|
|
@ -31,7 +31,8 @@ describe('Test plugin settings', function () {
|
||||||
npmName: 'peertube-plugin-test'
|
npmName: 'peertube-plugin-test'
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(registeredSettings.length).to.equal(1)
|
expect(registeredSettings.length).to.equal(3)
|
||||||
|
expect(registeredSettings.map(r => r.label)).to.have.members([ 'Unique setting', 'Unnamed 1', 'Unnamed 2' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return the latest registered settings', async function () {
|
it('Should return the latest registered settings', async function () {
|
||||||
|
|
|
@ -204,7 +204,8 @@ export class RegisterHelpers {
|
||||||
private buildRegisterSetting () {
|
private buildRegisterSetting () {
|
||||||
return (options: RegisterServerSettingOptions) => {
|
return (options: RegisterServerSettingOptions) => {
|
||||||
this.settings = [
|
this.settings = [
|
||||||
...this.settings.filter((s) => s.name !== options.name),
|
...this.settings.filter(s => !s.name || s.name !== options.name),
|
||||||
|
|
||||||
options
|
options
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue