From ccb38fa9a481f8159357859b8d291633c1294af1 Mon Sep 17 00:00:00 2001 From: brave-builds Date: Fri, 7 Feb 2025 16:46:21 +0000 Subject: [PATCH] Uplift of #27450 (squashed) to beta --- .../brave_sync_page/brave_sync_code_dialog.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts b/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts index 953aad09eed5..ce8e5b2ac4e2 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts +++ b/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts @@ -78,7 +78,7 @@ export class SettingsBraveSyncCodeDialogElement extends SettingsBraveSyncCodeDia ]; } - private syncCode: string; + private syncCode: string | undefined; private codeType: 'qr' | 'words' | 'choose' | 'input' | null; private syncCodeValidationError: string; private syncCodeWordCount_: number; @@ -89,16 +89,12 @@ export class SettingsBraveSyncCodeDialogElement extends SettingsBraveSyncCodeDia syncBrowserProxy_: BraveSyncBrowserProxy = BraveSyncBrowserProxy.getInstance(); async computeSyncCodeWordCount_() { - if (this.codeType !== 'input') { - return - } - - if (!this.syncCode) { + if (this.codeType !== 'words' && this.codeType !== 'input') { return } this.syncCodeWordCount_ = - await this.syncBrowserProxy_.getWordsCount(this.syncCode) + await this.syncBrowserProxy_.getWordsCount(this.syncCode ?? '') } isCodeType(askingType: string) { @@ -125,6 +121,10 @@ export class SettingsBraveSyncCodeDialogElement extends SettingsBraveSyncCodeDia } handleSyncCodeCopy_() { + if (!this.syncCode) { + console.warn('Skip handleSyncCodeCopy because code words are empty') + return + } window.clearTimeout(this.hasCopiedSyncCodeTimer_) navigator.clipboard.writeText(this.syncCode) this.hasCopiedSyncCode_ = true