@@ -664,10 +664,6 @@ angular.module('mm.core')
664664 * If not defined, modal won't be automatically closed.
665665 */
666666 self . showErrorModal = function ( errorMessage , needsTranslate , autocloseTime ) {
667- var errorKey = 'mm.core.error' ,
668- langKeys = [ errorKey ] ,
669- matches ;
670-
671667 if ( angular . isObject ( errorMessage ) ) {
672668 // We received an object instead of a string. Search for common properties.
673669 if ( typeof errorMessage . content != 'undefined' ) {
@@ -684,31 +680,33 @@ angular.module('mm.core')
684680 }
685681
686682 // Try to remove tokens from the contents.
687- matches = errorMessage . match ( / t o k e n " ? [ = | : ] " ? ( \w * ) / , '' ) ;
683+ var matches = errorMessage . match ( / t o k e n " ? [ = | : ] " ? ( \w * ) / , '' ) ;
688684 if ( matches && matches [ 1 ] ) {
689685 errorMessage = errorMessage . replace ( new RegExp ( matches [ 1 ] , 'g' ) , 'secret' ) ;
690686 }
691687 }
692688
693- if ( needsTranslate ) {
694- langKeys . push ( errorMessage ) ;
695- }
696-
697- $translate ( langKeys ) . then ( function ( translations ) {
698- var message = $mmText . decodeHTML ( needsTranslate ? translations [ errorMessage ] : errorMessage ) ,
699- popup = $ionicPopup . alert ( {
700- title : $mmText . decodeHTML ( translations [ errorKey ] ) ,
701- template : addFormatTextIfNeeded ( message ) // Add format-text to handle links.
702- } ) ;
689+ var message = $mmText . decodeHTML ( needsTranslate ? $translate . instant ( errorMessage ) : errorMessage ) ,
690+ popup = $ionicPopup . alert ( {
691+ title : getErrorTitle ( message ) ,
692+ template : addFormatTextIfNeeded ( message ) // Add format-text to handle links.
693+ } ) ;
703694
704- if ( typeof autocloseTime != 'undefined' && ! isNaN ( parseInt ( autocloseTime ) ) ) {
705- $timeout ( function ( ) {
706- popup . close ( ) ;
707- } , parseInt ( autocloseTime ) ) ;
708- }
709- } ) ;
695+ if ( typeof autocloseTime != 'undefined' && ! isNaN ( parseInt ( autocloseTime ) ) ) {
696+ $timeout ( function ( ) {
697+ popup . close ( ) ;
698+ } , parseInt ( autocloseTime ) ) ;
699+ }
710700 } ;
711701
702+ function getErrorTitle ( message ) {
703+ if ( message == $translate . instant ( 'mm.core.networkerrormsg' ) ) {
704+ return '<span class="mm-icon-with-badge"><i class="icon ion-wifi"></i>\
705+ <i class="icon ion-alert-circled mm-icon-badge"></i></span>' ;
706+ }
707+ return $mmText . decodeHTML ( $translate . instant ( 'mm.core.error' ) ) ;
708+ }
709+
712710 /**
713711 * Show a modal with an error message specifying a default message if error is empty.
714712 *
0 commit comments