From dffbf8b57788b83282e89fcfbba4d7388dad13ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 23 Dec 2021 11:25:54 +0100 Subject: [PATCH] Fix broken plugin state --- peertube-plugin-auth-openid-connect/main.js | 7 ++++++- .../client/video-edit-client-plugin.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/peertube-plugin-auth-openid-connect/main.js b/peertube-plugin-auth-openid-connect/main.js index 052e2f1..74d29a6 100644 --- a/peertube-plugin-auth-openid-connect/main.js +++ b/peertube-plugin-auth-openid-connect/main.js @@ -125,7 +125,12 @@ async function register ({ if (settings['auth-display-name']) store.authDisplayName = settings['auth-display-name'] }) - await loadSettingsAndCreateClient(registerExternalAuth, unregisterExternalAuth, peertubeHelpers, settingsManager) + try { + await loadSettingsAndCreateClient(registerExternalAuth, unregisterExternalAuth, peertubeHelpers, settingsManager) + } catch (err) { + logger.error('Cannot load settings and create open id client.', { err }) + } + store.authDisplayName = await settingsManager.getSetting('auth-display-name') } diff --git a/peertube-plugin-hello-world/client/video-edit-client-plugin.js b/peertube-plugin-hello-world/client/video-edit-client-plugin.js index 22283bc..30c429d 100644 --- a/peertube-plugin-hello-world/client/video-edit-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-edit-client-plugin.js @@ -26,10 +26,26 @@ function register ({ registerHook, registerVideoField }) { type: 'input-checkbox' } + const commonOptions4 = { + name: 'hello-world-field-4', + label: 'Super field 4 in main tab', + type: 'input-checkbox', + hidden: ({ formValues }) => { + return formValues['privacy'] !== 1 && formValues['privacy'] !== 2 + }, + error: ({ formValues, value }) => { + if (formValues['privacy'] !== 1 && formValues['privacy'] !== 2) return { error: false } + if (value === true) return { error: false } + + return { error: true, text: 'Should be enabled' } + } + } + for (const type of [ 'upload', 'import-url', 'update' ]) { registerVideoField(commonOptions1, { type }) registerVideoField(commonOptions2, { type }) registerVideoField(commonOptions3, { type }) + registerVideoField(commonOptions4, { type, tab: 'main' }) } }