Skip to content
Snippets Groups Projects
Commit 111b1f57 authored by ubermanu's avatar ubermanu
Browse files

move deferred into utils and some plugins into the plugins folder

parent 8aae8505
No related branches found
No related tags found
2 merge requests!103Update master with beta,!101Clean code and separate concerns
/**
* Transform hats to custom values.
*/
converse.plugins.add('sib-custom-hats', {
overrides: {
getHats: function() {
const hat_conversions = { 'admin': 'Administrateur' };
const hats = this.__super__.getHats.apply(this, arguments);
if (!hat_conversions) {
return hats;
} else {
const role_affiliations = Object.keys(hat_conversions);
return hats.map((hat) => {
if (role_affiliations.includes(hat.title)) {
return ({ title: hat_conversions[hat.title] });
} else {
return hat;
}
});
}
},
},
});
/**
* Override converse's request permission with an empty function
* so that permission request for notifications don't happen.
*/
converse.plugins.add('sib-remove-notifications', {
overrides: {
requestPermission: function() {
},
showMessageNotification: function() {
},
showChatStateNotification: function() {
},
showContactRequestNotification: function() {
},
showFeedbackNotification: function() {
},
handleChatStateNotification: function() {
},
handleMessageNotification: function() {
},
handleContactRequestNotification: function() {
},
handleFeedback: function() {
},
},
});
import './conversejs/converse.min.js';
import './conversejs/emojis.js';
import './plugins/converse-rai.js';
import { Sib, store, StoreMixin } from 'https://cdn.skypack.dev/@startinblox/core@0.15';
import { Deferred } from './utils.js';
import ComponentPath from './path.js';
class Deferred {
constructor() {
this.promise = new Promise(((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
}).bind(this));
this.then = this.promise.then.bind(this.promise);
this.catch = this.promise.catch.bind(this.promise);
}
}
import './conversejs/converse.min.js';
import './conversejs/emojis.js';
import './plugins/converse-rai.js';
import './plugins/sib-custom-hats.js';
import './plugins/sib-remove-notifications.js';
export const SolidXMPPChat = {
name: 'solid-xmpp-chat',
......@@ -314,65 +308,6 @@ export const SolidXMPPChat = {
},
});
// Transform hats to custom values
converse.plugins.add('custom-hats', {
overrides: {
getHats: function() {
const hat_conversions = { 'admin': 'Administrateur' };
const _converse = this;
const hats = _converse.__super__.getHats.apply(this, arguments);
if (!hat_conversions) {
return hats;
} else {
const role_affiliations = Object.keys(hat_conversions);
const custom_hats = hats.map((hat) => {
if (role_affiliations.includes(hat.title)) {
return ({ title: hat_conversions[hat.title] });
} else {
return hat;
}
});
return custom_hats;
}
},
},
});
//Highly experimental DO NOT USE
// converse.plugins.add('custom-storage', {
// overrides: {
// createStore: function () {
// const _converse = this;
// if (arguments.length > 1){
// arguments[1] = "none";
// }
// return _converse.__super__.createStore.apply(this, arguments);
// }
// }
// });
//Override converse's request permission with an empty function
//so that permission request for notifications don't happen
converse.plugins.add('remove-notifications', {
overrides: {
requestPermission: function() {
},
showMessageNotification: function() {
},
showChatStateNotification: function() {
},
showContactRequestNotification: function() {
},
showFeedbackNotification: function() {
},
handleChatStateNotification: function() {
},
handleMessageNotification: function() {
},
handleContactRequestNotification: function() {
},
handleFeedback: function() {
},
},
});
// Initialize deferred resolution plugin
converse.plugins.add('conversejs-sib-focused', {
initialize() {
......@@ -463,7 +398,7 @@ export const SolidXMPPChat = {
'conversejs-changechat',
'conversejs-rai',
'custom-hats',
'remove-notifications',
'sib-remove-notifications',
],
});
......
export class Deferred {
constructor() {
this.promise = new Promise(((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
}).bind(this));
this.then = this.promise.then.bind(this.promise);
this.catch = this.promise.catch.bind(this.promise);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment