Fix loading ssh and gpg keys

We have to use queryAsync to be able to wait for sshEditor or gpgEditor
to load. This is because in the render() we wait on serverConfig
to be generated and in the process the element is removed not
hidden.

Release-Notes: Fix loading ssh and gpg keys
Bug: Issue 15957
Change-Id: I6f986f8485e5209f5e0940f07cd7502f1fe28caf
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
index 94c21f6..9c448d9 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
@@ -59,7 +59,13 @@
 import {windowLocationReload} from '../../../utils/dom-util';
 import {BindValueChangeEvent, ValueChangedEvent} from '../../../types/events';
 import {LitElement, css, html} from 'lit';
-import {customElement, property, query, state} from 'lit/decorators';
+import {
+  customElement,
+  property,
+  query,
+  queryAsync,
+  state,
+} from 'lit/decorators';
 import {sharedStyles} from '../../../styles/shared-styles';
 import {paperStyles} from '../../../styles/gr-paper-styles';
 import {fontStyles} from '../../../styles/gr-font-styles';
@@ -106,9 +112,9 @@
 
   @query('#diffPrefs') diffPrefs!: GrDiffPreferences;
 
-  @query('#sshEditor') sshEditor?: GrSshEditor;
+  @queryAsync('#sshEditor') sshEditorPromise!: Promise<GrSshEditor>;
 
-  @query('#gpgEditor') gpgEditor?: GrGpgEditor;
+  @queryAsync('#gpgEditor') gpgEditorPromise!: Promise<GrGpgEditor>;
 
   @query('#emailEditor', true) emailEditor!: GrEmailEditor;
 
@@ -240,12 +246,16 @@
         this.serverConfig = config;
         const configPromises: Array<Promise<void>> = [];
 
-        if (this.serverConfig?.sshd && this.sshEditor) {
-          configPromises.push(this.sshEditor.loadData());
+        if (this.serverConfig?.sshd) {
+          configPromises.push(
+            this.sshEditorPromise.then(sshEditor => sshEditor.loadData())
+          );
         }
 
-        if (this.serverConfig?.receive?.enable_signed_push && this.gpgEditor) {
-          configPromises.push(this.gpgEditor.loadData());
+        if (this.serverConfig?.receive?.enable_signed_push) {
+          configPromises.push(
+            this.gpgEditorPromise.then(gpgEditor => gpgEditor.loadData())
+          );
         }
 
         configPromises.push(