Commit a44f3832 authored by JC Brand's avatar JC Brand

Only create bookmark after succesfully setting it on the server

parent 34541d64
...@@ -290,8 +290,9 @@ ...@@ -290,8 +290,9 @@
}, },
createBookmark (options) { createBookmark (options) {
_converse.bookmarks.create(options); _converse.bookmarks.sendBookmarkStanza()
_converse.bookmarks.sendBookmarkStanza(); .then(() => _converse.bookmarks.create(options))
.catch(() => this.onBookmarkError.apply(this, arguments));
}, },
sendBookmarkStanza () { sendBookmarkStanza () {
...@@ -319,17 +320,16 @@ ...@@ -319,17 +320,16 @@
.c('value').t('true').up().up() .c('value').t('true').up().up()
.c('field', {'var':'pubsub#access_model'}) .c('field', {'var':'pubsub#access_model'})
.c('value').t('whitelist'); .c('value').t('whitelist');
_converse.connection.sendIQ(stanza, null, this.onBookmarkError.bind(this)); return _converse.api.sendIQ(stanza);
}, },
onBookmarkError (iq) { onBookmarkError (iq) {
_converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR); _converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR);
_converse.log(iq); _converse.log(iq);
// We remove all locally cached bookmarks and fetch them _converse.api.alert.show(
// again from the server. Strophe.LogLevel.ERROR,
this.reset(); __('Error'), [__("Sorry, something went wrong while trying to save your bookmark.")]
this.fetchBookmarksFromServer(null); )
window.alert(__("Sorry, something went wrong while trying to save your bookmark."));
}, },
fetchBookmarksFromServer (deferred) { fetchBookmarksFromServer (deferred) {
......
...@@ -1102,7 +1102,7 @@ ...@@ -1102,7 +1102,7 @@
fetchMembers () { fetchMembers () {
this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']) this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin'])
.then((new_members) => { .then(new_members => {
const new_jids = new_members.map(m => m.jid).filter(m => !_.isUndefined(m)), const new_jids = new_members.map(m => m.jid).filter(m => !_.isUndefined(m)),
new_nicks = new_members.map(m => !m.jid && m.nick || undefined).filter(m => !_.isUndefined(m)), new_nicks = new_members.map(m => !m.jid && m.nick || undefined).filter(m => !_.isUndefined(m)),
removed_members = this.filter(m => { removed_members = this.filter(m => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment