bigbluebutton-html-plugin-sdk
Version:
This repository contains the SDK for developing BigBlueButton plugins. Plugins are React components that can be loaded from external sources by the BigBlueButton HTML5 client to extend its functionalities.
60 lines • 2.83 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var ui_data_hooks_1 = require("../../../../ui-data-hooks");
var utils_1 = require("../../../../utils");
var subscriptions_1 = require("./subscriptions");
function useLocaleMessagesAuxiliary(_a) {
var pluginApi = _a.pluginApi, fetchConfigs = _a.fetchConfigs;
var currentLocale = pluginApi.useUiData(ui_data_hooks_1.IntlLocaleUiDataNames.CURRENT_LOCALE, {
locale: 'en',
fallbackLocale: 'en',
});
var _b = React.useState(true), loading = _b[0], setLoading = _b[1];
var _c = React.useState({}), messages = _c[0], setMessages = _c[1];
var pluginInformation = pluginApi.useCustomSubscription(subscriptions_1.GET_PLUGIN_INFORMATION).data;
React.useEffect(function () {
if (pluginInformation && pluginInformation.plugin && currentLocale.locale) {
var localesBaseUrl = pluginInformation.plugin[0].localesBaseUrl;
var locale = currentLocale.locale;
var localeUrl_1 = "".concat(localesBaseUrl, "/").concat(locale, ".json");
fetch(localeUrl_1, fetchConfigs).then(function (result) { return result.json(); }).then(function (localeMessages) {
setLoading(false);
setMessages(localeMessages);
}).catch(function (err) {
setLoading(false);
utils_1.pluginLogger.error("Something went wrong while trying to fetch ".concat(localeUrl_1, ": "), err);
});
}
}, [pluginInformation, currentLocale]);
return {
messages: messages,
loading: loading,
currentLocale: currentLocale.locale,
};
}
exports.default = useLocaleMessagesAuxiliary;
//# sourceMappingURL=useLocaleMessages.js.map