changeset 18:3c02cbced2df

Disable default MAM prefs until we received the iq result.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 22 Dec 2018 19:46:16 +0100
parents 07543f7f5e89
children bde4f0bbfe69
files index.xhtml mam.js
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/index.xhtml
+++ b/index.xhtml
@@ -139,7 +139,7 @@ Enter your nickname, so people you know 
 </div>
 <div class="col-sm-8">
 <p>
-<label>Which messages to store in your archive? <select id="mam-default">
+<label>Which messages to store in your archive? <select id="mam-default" disabled="">
 <option value="always">All messages</option>
 <option value="never">No messages</option>
 <option value="roster">Messages from your contacts only</option>
--- a/mam.js
+++ b/mam.js
@@ -7,6 +7,7 @@ function initMAM(connection) {
     const iq = $iq({type: 'get'})
         .c('prefs', {xmlns: NS.mam});
     connection.sendIQ(iq, onMAMPrefs, onMAMPrefsError.bind(null, 'query failed.'));
+    displaySpinner(prefs_spinner);
 
     function onMAMPrefs(result_iq)
     {
@@ -15,6 +16,8 @@ function initMAM(connection) {
             return onMAMPrefsError('server error.');
         const default_ = prefs.getAttributeNS(null, 'default');
         prefs_default.value = default_;
+        prefs_default.disabled = false;
+        hideSpinner(prefs_spinner);
         const always = parseXPath(prefs, './mam:always/mam:jid', XPathResult.ORDERED_NODE_ITERATOR_TYPE);
         while (true) {
             const item = always.iterateNext();
@@ -36,6 +39,7 @@ function initMAM(connection) {
     function onMAMPrefsError(string)
     {
         console.log('Failed to retrieve your message archiving preferences: ' + string);
+        spinnerError(prefs_spinner);
     }
 
     prefs_default.addEventListener('change', function (evt) {