Moved document matching to use urlId to prevent issues with renamed documents
This commit is contained in:
@ -90,6 +90,10 @@ type Props = {
|
|||||||
if (document) {
|
if (document) {
|
||||||
this.props.ui.setActiveDocument(document);
|
this.props.ui.setActiveDocument(document);
|
||||||
document.view();
|
document.view();
|
||||||
|
|
||||||
|
// Update url to match the current one
|
||||||
|
const urlParts = this.props.match.url.split('/');
|
||||||
|
this.props.history.replace([document.url, urlParts.slice(3)].join('/'));
|
||||||
} else {
|
} else {
|
||||||
// Render 404 with search
|
// Render 404 with search
|
||||||
this.setState({ notFound: true });
|
this.setState({ notFound: true });
|
||||||
|
@ -138,8 +138,11 @@ class DocumentsStore extends BaseStore {
|
|||||||
return this.data.get(id);
|
return this.data.get(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match documents by the url ID as the title slug can change
|
||||||
|
*/
|
||||||
getByUrl = (url: string): ?Document => {
|
getByUrl = (url: string): ?Document => {
|
||||||
return _.find(this.data.values(), { url });
|
return _.find(this.data.values(), doc => url.endsWith(doc.urlId));
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(options: Options) {
|
constructor(options: Options) {
|
||||||
|
@ -17,6 +17,7 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
|||||||
const data = {
|
const data = {
|
||||||
id: document.id,
|
id: document.id,
|
||||||
url: document.getUrl(),
|
url: document.getUrl(),
|
||||||
|
urlId: document.urlId,
|
||||||
private: document.private,
|
private: document.private,
|
||||||
title: document.title,
|
title: document.title,
|
||||||
text: document.text,
|
text: document.text,
|
||||||
|
Reference in New Issue
Block a user