DEV: Make api version optional (#31160)

We'll be making this change more deeply soon. For now, this is the
minimum change required to a this version-free syntax work under
Discourse 3.4.0.
This commit is contained in:
David Taylor 2025-02-04 10:19:04 +00:00 committed by GitHub
parent 50337a7595
commit acad83199e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3466,7 +3466,14 @@ function getPluginApi(version) {
* @param {object} [opts] - Optional additional options to pass to the callback function.
* @returns {*} The result of the `callback` function, if executed
*/
export function withPluginApi(version, apiCodeCallback, opts) {
export function withPluginApi(...args) {
let version, apiCodeCallback, opts;
if (typeof args[0] === "function") {
[version, apiCodeCallback, opts] = ["0", ...args];
} else {
[version, apiCodeCallback, opts] = args;
}
opts = opts || {};
const api = getPluginApi(version);