0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-18 18:42:41 +00:00

Exclude self from brew themes list to prevent circular ref.

This commit is contained in:
David Bolack
2024-02-23 17:12:54 -06:00
parent 3e66647f9f
commit 2456432844

View File

@@ -42,7 +42,7 @@ const sanitizeBrew = (brew, accessType)=>{
return brew; return brew;
}; };
const getUsersBrewThemes = async (username)=>{ const getUsersBrewThemes = async (username,id)=>{
const fields = [ const fields = [
'title', 'title',
'tags', 'tags',
@@ -59,14 +59,16 @@ const getUsersBrewThemes = async (username)=>{
}; };
brews.forEach((brew)=>{ brews.forEach((brew)=>{
userThemes.Brew[brew.editId] = { if(id!=brew.editId) {
name : brew.title, userThemes.Brew[brew.editId] = {
renderer : 'V3', name : brew.title,
baseTheme : false, renderer : 'V3',
baseSnippets : false, baseTheme : false,
path : `#${brew.editId}`, baseSnippets : false,
thumbnail : brew.thumbnail path : `#${brew.editId}`,
}; thumbnail : brew.thumbnail
};
}
}); });
return userThemes; return userThemes;
@@ -324,7 +326,7 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), async(req, res, next)=>{
type : 'article' type : 'article'
}; };
req.brew.userThemes = await getUsersBrewThemes(req.account.username); req.brew.userThemes = await getUsersBrewThemes(req.account.username, req.brew.editId);
sanitizeBrew(req.brew, 'edit'); sanitizeBrew(req.brew, 'edit');
splitTextStyleAndMetadata(req.brew); splitTextStyleAndMetadata(req.brew);
res.header('Cache-Control', 'no-cache, no-store'); //reload the latest saved brew when pressing back button, not the cached version before save. res.header('Cache-Control', 'no-cache, no-store'); //reload the latest saved brew when pressing back button, not the cached version before save.