Просмотр исходного кода

Add readyToSubmit property to WebClientService

Lennart Grahl 6 лет назад
Родитель
Сommit
d57682477a
2 измененных файлов с 11 добавлено и 4 удалено
  1. 1 4
      src/partials/messenger.ts
  2. 10 0
      src/services/webclient.ts

+ 1 - 4
src/partials/messenger.ts

@@ -546,10 +546,7 @@ class ConversationController {
     public submit = (type: threema.MessageContentType, contents: threema.MessageData[]): Promise<any> => {
         // Validate whether a connection is available
         return new Promise((resolve, reject) => {
-            if (!this.stateService.readyToSubmit(
-                this.webClientService.chosenTask,
-                this.webClientService.startupDone,
-            )) {
+            if (!this.webClientService.readyToSubmit) {
                 // Invalid connection, show toast and abort
                 this.showError(this.$translate.instant('error.NO_CONNECTION'));
                 return reject();

+ 10 - 0
src/services/webclient.ts

@@ -369,6 +369,16 @@ export class WebClientService {
         this.stateService.evtGlobalConnectionStateChange.attach(this.handleGlobalConnectionStateChange.bind(this));
     }
 
+    /**
+     * Return whether wire messages can be sent (or queued to be sent).
+     *
+     * Note: This will not return `true` before an initial connection has been
+     *       established successfully.
+     */
+    get readyToSubmit(): boolean {
+        return this.stateService.readyToSubmit(this.chosenTask, this.startupDone);
+    }
+
     get me(): threema.MeReceiver {
         return this.receivers.me;
     }