From cfdfdce2fe66175a4e1482eb04a363f6805ed8a7 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Sun, 17 Oct 2021 20:00:02 +0800 Subject: [PATCH] Hush repetitive debug errors + remove from i18n --- static/app-strings.json | 4 ---- ui/util/lbryURI.js | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 54218a04a..2d6c94f05 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -469,11 +469,8 @@ "New --[clears Publish Form]--": "New", "Loading": "Loading", "This file is in your library.": "This file is in your library.", - "'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url.": "'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url.", "Invalid claim ID %s.": "Invalid claim ID %s.", - "'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead": "'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead", "View Tag": "View Tag", - "'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead": "'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead", "Vietnamese": "Vietnamese", "Thai": "Thai", "Arabic": "Arabic", @@ -486,7 +483,6 @@ "Greek": "Greek", "Hide": "Hide", "Persian": "Persian", - "'contentName' should no longer be used. Use 'streamName' instead": "'contentName' should no longer be used. Use 'streamName' instead", "Sorry, we can't preview this file.": "Sorry, we can't preview this file.", "View File": "View File", "Close": "Close", diff --git a/ui/util/lbryURI.js b/ui/util/lbryURI.js index bdc1ad0a1..dc6df9c42 100644 --- a/ui/util/lbryURI.js +++ b/ui/util/lbryURI.js @@ -171,6 +171,15 @@ function parseURIModifier(modSeperator: ?string, modValue: ?string) { return [claimId, claimSequence, bidPosition]; } +const errorHistory = []; + +function logErrorOnce(err: string) { + if (!errorHistory.includes(err)) { + errorHistory.push(err); + console.error(err); + } +} + /** * Takes an object in the same format returned by parse() and builds a URI. * @@ -193,20 +202,18 @@ export function buildURI(UrlObj: LbryUrlObj, includeProto: boolean = true, proto if (!isProduction) { if (claimId) { - console.error(__("'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead")); + logErrorOnce("'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead"); } if (claimName) { - console.error(__("'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead")); + logErrorOnce("'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead"); } if (contentName) { - console.error(__("'contentName' should no longer be used. Use 'streamName' instead")); + logErrorOnce("'contentName' should no longer be used. Use 'streamName' instead"); } } if (!claimName && !channelName && !streamName) { - console.error( - __("'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url.") - ); + console.error("'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url."); } const formattedChannelName = channelName && (channelName.startsWith('@') ? channelName : `@${channelName}`);