From 2a9d3fa4bcd9cb92ce031b3e7324f1d7e76050b5 Mon Sep 17 00:00:00 2001 From: zeldaroot Date: Sat, 30 Oct 2021 17:00:18 +0300 Subject: [PATCH] =?UTF-8?q?Removing=20=C2=ABnone=C2=BB=20values=20from=20a?= =?UTF-8?q?=20custom=20field=20(issue:=20https://github.com/CinemaPress/Ci?= =?UTF-8?q?nemaPress/issues/33)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/CP_save.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/CP_save.js b/lib/CP_save.js index f92d512..d3cb7a9 100644 --- a/lib/CP_save.js +++ b/lib/CP_save.js @@ -172,6 +172,28 @@ function saveContent(content_raw, name, callback) { ? result.custom : {} : {}; + Object.keys(cnt).forEach(function(key) { + if (typeof cnt[key] === 'string' && cnt[key] === 'none') { + delete cnt[key]; + if (res && res[key]) delete res[key]; + } else if ( + typeof cnt[key] === 'object' && + !Array.isArray(cnt[key]) && + cnt[key] + ) { + Object.keys(cnt[key]).forEach(function(key2) { + if ( + typeof cnt[key][key2] === 'string' && + cnt[key][key2] === 'none' + ) { + delete cnt[key][key2]; + if (res && res[key] && res[key][key2]) { + delete res[key][key2]; + } + } + }); + } + }); cnt = Object.assign({}, res, cnt); content.custom = JSON.stringify(cnt); } catch (e) {