瀏覽代碼

Merge pull request #956 from threema-ch/value-too-long-error

Some workarounds to alleviate message length problems reported through support.
Danilo Bargen 5 年之前
父節點
當前提交
7ec34a4c7e
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 8 2
      src/directives/compose_area.ts
  2. 3 1
      src/services/webclient.ts

+ 8 - 2
src/directives/compose_area.ts

@@ -202,7 +202,14 @@ export default [
                         // Check for max length
                         const byteLength = (new TextEncoder().encode(text)).length;
                         if (byteLength > scope.maxTextLength) {
-                            const pieces: string[] = stringService.byteChunk(text, scope.maxTextLength, 50);
+                            // Messages that use the entire available message size become a problem
+                            // when being quoted, since the quote also becomes part of the message.
+                            // As a workaround, until a better quote system is implemented, reduce
+                            // the chunk size so that reaching the limit becomes more unlikely.
+                            const chunkSize = scope.maxTextLength * 0.85;
+
+                            const pieces: string[] = stringService.byteChunk(text, chunkSize, 50);
+
                             const confirm = $mdDialog.confirm()
                                 .title($translate.instant('messenger.MESSAGE_TOO_LONG_SPLIT_SUBJECT'))
                                 .textContent($translate.instant('messenger.MESSAGE_TOO_LONG_SPLIT_BODY', {
@@ -211,7 +218,6 @@ export default [
                                 }))
                                 .ok($translate.instant('common.YES'))
                                 .cancel($translate.instant('common.NO'));
-
                             $mdDialog.show(confirm).then(function() {
                                 submitTexts(pieces);
                             }, () => {

+ 3 - 1
src/services/webclient.ts

@@ -1926,10 +1926,12 @@ export class WebClientService {
             // Determine error message
             let errorMessage;
             switch (error) {
-                case 'file_too_large': // TODO: deprecated
                 case 'fileTooLarge':
                     errorMessage = this.$translate.instant('error.FILE_TOO_LARGE_GENERIC');
                     break;
+                case 'valueTooLong':
+                    errorMessage = this.$translate.instant('validationError.modifyReceiver.valueTooLong');
+                    break;
                 case 'blocked':
                     errorMessage = this.$translate.instant('error.CONTACT_BLOCKED');
                     break;