Thank you, @merefield! I am stuck (at least I think that’s where
) at the javascript snippet for the back button…
discourse-tc-topic-next-button/javascripts/discourse/components/topic-previous-button.js at master · denvergeeks/discourse-tc-topic-next-button · GitHub where at the moment I have this…
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import {
nextTopicUrl,
previousTopicUrl,
} from "discourse/lib/topic-list-tracker";
import DiscourseURL from "discourse/lib/url";
import { inject as service } from "@ember/service";
export default class TopicPreviousButton extends Component {
@service site;
@tracked label = "";
@tracked showButton = false;
@tracked lastURL = "";
constructor(owner, args) {
super(owner, args);
previousTopicUrl().then((url) => {
if (url) {
this.showButton = true;
this.lastURL = url;
} else {
this.showButton = false;
this.lastURL = "";
}
})
};
get goFirst() {
return settings.topic_next_always_go_to_first_post
}
@action
goToPreviousTopic() {
let url;
if (this.lastURL) {
url = this.goFirst
? this.lastURL.substring(0, this.lastURL.nextIndexOf("/"))
: this.lastURL;
DiscourseURL.routeTo(url);
}
};
}
I think the problem is near the bottom at
? this.lastURL.substring(0, this.lastURL.nextIndexOf("/"))
Any thoughts?
I tried
? this.lastURL.substring(0, this.lastURL.indexOf("/"))