]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'main' into new-comment-space
authorSleeplessOne1917 <abias1122@gmail.com>
Sun, 25 Jun 2023 17:29:02 +0000 (17:29 +0000)
committerGitHub <noreply@github.com>
Sun, 25 Jun 2023 17:29:02 +0000 (17:29 +0000)
src/server/handlers/theme-handler.ts
src/shared/components/search.tsx

index b107d8542461732a5bf6b78ae6e57b11d0733ad3..456fb3bd00e0d646d03edb6634f4d50d4d03ea94 100644 (file)
@@ -11,22 +11,21 @@ export default async (req: Request, res: Response) => {
   const theme = req.params.name;
 
   if (!theme.endsWith(".css")) {
-    res.statusCode = 400;
-    res.send("Theme must be a css file");
+    return res.status(400).send("Theme must be a css file");
   }
 
   const customTheme = path.resolve(extraThemesFolder, theme);
 
   if (existsSync(customTheme)) {
-    res.sendFile(customTheme);
+    return res.sendFile(customTheme);
   } else {
     const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`);
 
     // If the theme doesn't exist, just send litely
     if (existsSync(internalTheme)) {
-      res.sendFile(internalTheme);
+      return res.sendFile(internalTheme);
     } else {
-      res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
+      return res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
     }
   }
 };
index 473b18c483c430177a5a011dd825ece643f19387..b58580e5d5b79f8482fb7097c7d711867fec192e 100644 (file)
@@ -332,7 +332,9 @@ export class Search extends Component<any, SearchState> {
   }
 
   async componentDidMount() {
-    if (!this.state.isIsomorphic) {
+    if (
+      !(this.state.isIsomorphic || this.props.history.location.state?.searched)
+    ) {
       const promises = [this.fetchCommunities()];
       if (this.state.searchText) {
         promises.push(this.search());
@@ -1095,7 +1097,9 @@ export class Search extends Component<any, SearchState> {
       sort: sort ?? urlSort,
     };
 
-    this.props.history.push(`/search${getQueryString(queryParams)}`);
+    this.props.history.push(`/search${getQueryString(queryParams)}`, {
+      searched: true,
+    });
 
     await this.search();
   }