Skip to content

Commit

Permalink
fix syntax error plus remove all leading slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfaffman committed Dec 14, 2023
1 parent e41656f commit 4377069
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions javascripts/discourse/initializers/custom-homepage-set.js.es6
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import mobile from "discourse/lib/mobile";
import { withPluginApi } from "discourse/lib/plugin-api";
import PreloadStore from "discourse/lib/preload-store";
import { setDefaultHomepage } from "discourse/lib/utilities";

export default {
name: "discourse-custom-homepage",
initialize(container) {
withPluginApi("0.11.4", (api) => {
const router = container.lookup("router:main");
const user = api.getCurrentUser();
if (user && user.primary_group_name) {
if (settings.group_page_map) {
const { setDefaultHomepage } = require("discourse/lib/utilities");

window.console.log("checking default");

if (settings.custom_default_homepage) {
const url = settings.custom_default_homepage;
const url = settings.custom_default_homepage.replace(/^\/+/g, '');
setDefaultHomepage(url);
PreloadStore.remove("topic_list");
}

if (!user && settings.anon_page) {
const url = settings.anon_page;
const url = settings.anon_page.replace(/^\/+/g, '');
setDefaultHomepage(url);
PreloadStore.remove("topic_list");
}

if (mobile.isMobileDevice && settings.mobile_homepage) {
const url = settings.mobile_homepage;
const url = settings.mobile_homepage.replace(/^\/+/g, '');
setDefaultHomepage(url);
PreloadStore.remove("topic_list");
}
Expand All @@ -36,8 +37,8 @@ export default {
RegExp(user.primary_group_name).test(value)
);
if (mapEntry) {
const url = mapEntry.split(":")[1];
if (url.charAt(0) == "/") url = url.substr(1);
const url = mapEntry.split(":")[1].replace(/^\/+/g, '');
window.console.log("setting url", url);
setDefaultHomepage(url);
PreloadStore.remove("topic_list");
}
Expand Down

0 comments on commit 4377069

Please sign in to comment.