0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

IMPROVE: Move pending wizard check to page change event

Dieser Commit ist enthalten in:
merefield 2023-07-07 17:16:51 +01:00
Ursprung eadd64bbbc
Commit 10df3208df
2 geänderte Dateien mit 54 neuen und 80 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,24 @@ export default {
};
withPluginApi("0.8.36", (api) => {
api.onAppEvent('page:changed', (data) => {
const currentUser = container.lookup("service:current-user");
const settings = container.lookup("service:site-settings");
const redirectToWizard = currentUser.redirect_to_wizard;
const excludedPaths = settings.wizard_redirect_exclude_paths
.split("|")
.concat(["loading"]);
if (
redirectToWizard &&
(data.currentRouteName !== "customWizardStep") &&
!(excludedPaths.find((p) => {
return data.currentRouteName.indexOf(p) > -1;
}))
) {
window.location = "/w/" + redirectToWizard.dasherize();
}
});
api.modifyClass("component:d-navigation", {
pluginId: "custom-wizard",
actions: {

Datei anzeigen

@ -1,44 +0,0 @@
export default {
name: "custom-wizard-redirect",
after: "message-bus",
initialize: function (container) {
const messageBus = container.lookup("service:message-bus");
const siteSettings = container.lookup("service:site-settings");
if (!siteSettings.custom_wizard_enabled || !messageBus) {
return;
}
messageBus.subscribe("/redirect_to_wizard", function (wizardId) {
const wizardUrl = window.location.origin + "/w/" + wizardId;
window.location.href = wizardUrl;
});
const ApplicationRoute = requirejs("discourse/routes/application").default;
ApplicationRoute.reopen({
actions: {
willTransition(transition) {
const redirectToWizard = this.get("currentUser.redirect_to_wizard");
const excludedPaths = this.siteSettings.wizard_redirect_exclude_paths
.split("|")
.concat(["loading"]);
if (
redirectToWizard &&
(!transition.intent.name ||
!excludedPaths.find((p) => {
return transition.intent.name.indexOf(p) > -1;
}))
) {
transition.abort();
window.location = "/w/" + redirectToWizard.dasherize();
}
return this._super(transition);
},
},
});
},
};