Fix registering unamed settings

pull/6527/head
Chocobozzz 2024-07-10 12:12:07 +02:00
parent 6d12f018cd
commit c5de5ef1d0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 14 additions and 2 deletions

View File

@ -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 = [
'action:application.listening',
'action:notifier.notification.created',

View File

@ -31,7 +31,8 @@ describe('Test plugin settings', function () {
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 () {

View File

@ -204,7 +204,8 @@ export class RegisterHelpers {
private buildRegisterSetting () {
return (options: RegisterServerSettingOptions) => {
this.settings = [
...this.settings.filter((s) => s.name !== options.name),
...this.settings.filter(s => !s.name || s.name !== options.name),
options
]
}