diff --git a/lemmy-translations b/lemmy-translations
index 2e9f6291..1cbac3a1 160000
--- a/lemmy-translations
+++ b/lemmy-translations
@@ -1 +1 @@
-Subproject commit 2e9f6291c91a9c97fa7f7740f90ee3146515e03c
+Subproject commit 1cbac3a1521e26b9b5c1c97a0c9852655ddcf00b
diff --git a/package.json b/package.json
index 729b6b10..d928bf9c 100644
--- a/package.json
+++ b/package.json
@@ -74,7 +74,7 @@
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"import-sort-style-module": "^6.0.0",
- "lemmy-js-client": "0.16.4-rc.1",
+ "lemmy-js-client": "0.17.0-rc.5",
"lint-staged": "^12.4.1",
"mini-css-extract-plugin": "^2.6.0",
"node-fetch": "^2.6.1",
diff --git a/src/server/index.tsx b/src/server/index.tsx
index cdd0f0ad..41a6ec8e 100644
--- a/src/server/index.tsx
+++ b/src/server/index.tsx
@@ -27,18 +27,15 @@ const [hostname, port] = process.env["LEMMY_UI_HOST"]
const extraThemesFolder =
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
-server.use(function (_req, res, next) {
- // in debug mode, websocket backend may be on another port, so we need to permit it in csp policy
- var websocketBackend;
- if (process.env.NODE_ENV == "development") {
- websocketBackend = wsUriBase;
- }
- res.setHeader(
- "Content-Security-Policy",
- `default-src 'none'; connect-src 'self' ${websocketBackend}; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'`
- );
- next();
-});
+if (process.env.NODE_ENV !== "development") {
+ server.use(function (_req, res, next) {
+ res.setHeader(
+ "Content-Security-Policy",
+ `default-src 'none'; connect-src 'self' ${wsUriBase}; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'`
+ );
+ next();
+ });
+}
server.use(express.json());
server.use(express.urlencoded({ extended: false }));
server.use("/static", express.static(path.resolve("./dist")));
diff --git a/src/shared/components/common/listing-type-select.tsx b/src/shared/components/common/listing-type-select.tsx
index 4d00c462..515f2dc8 100644
--- a/src/shared/components/common/listing-type-select.tsx
+++ b/src/shared/components/common/listing-type-select.tsx
@@ -6,7 +6,8 @@ import { randomStr } from "../../utils";
interface ListingTypeSelectProps {
type_: ListingType;
- showLocal?: boolean;
+ showLocal: boolean;
+ showSubscribed: boolean;
onChange?(val: ListingType): any;
}
@@ -33,15 +34,17 @@ export class ListingTypeSelect extends Component<
return {
type_: props.type_,
showLocal: props.showLocal,
+ showSubscribed: props.showSubscribed,
};
}
render() {
return (
-
+ >
+
+ {i18n.t("subscribed")}
+
+ )}
{this.props.showLocal && (
diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx
index b98da1f0..f848f8a3 100644
--- a/src/shared/components/home/admin-settings.tsx
+++ b/src/shared/components/home/admin-settings.tsx
@@ -21,6 +21,7 @@ import {
isBrowser,
randomStr,
setIsoData,
+ showLocal,
toast,
wsClient,
wsJsonToRes,
@@ -133,7 +134,10 @@ export class AdminSettings extends Component {
path={this.context.router.route.match.url}
/>
{this.state.siteRes.site_view.site.id && (
-
+
)}
{this.admins()}
{this.bannedUsers()}
diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx
index 0010cd91..f52efec2 100644
--- a/src/shared/components/home/home.tsx
+++ b/src/shared/components/home/home.tsx
@@ -110,7 +110,12 @@ export class Home extends Component {
loading: true,
posts: [],
comments: [],
- listingType: getListingTypeFromProps(this.props),
+ listingType: getListingTypeFromProps(
+ this.props,
+ ListingType[
+ this.isoData.site_res.site_view.site.default_post_listing_type
+ ]
+ ),
dataType: getDataTypeFromProps(this.props),
sort: getSortTypeFromProps(this.props),
page: getPageFromProps(this.props),
@@ -173,7 +178,7 @@ export class Home extends Component {
static getDerivedStateFromProps(props: any): HomeProps {
return {
- listingType: getListingTypeFromProps(props),
+ listingType: getListingTypeFromProps(props, ListingType.Local),
dataType: getDataTypeFromProps(props),
sort: getSortTypeFromProps(props),
page: getPageFromProps(props),
@@ -194,7 +199,7 @@ export class Home extends Component {
UserService.Instance.myUserInfo.local_user_view.local_user
.default_listing_type
]
- : ListingType.Local;
+ : null;
let sort: SortType = pathSplit[7]
? SortType[pathSplit[7]]
: UserService.Instance.myUserInfo
@@ -213,9 +218,12 @@ export class Home extends Component {
page,
limit: fetchLimit,
sort,
- type_,
saved_only: false,
};
+ if (type_) {
+ getPostsForm.type_ = type_;
+ }
+
setOptionalAuth(getPostsForm, req.auth);
promises.push(req.client.getPosts(getPostsForm));
} else {
@@ -223,7 +231,7 @@ export class Home extends Component {
page,
limit: fetchLimit,
sort,
- type_,
+ type_: type_ || ListingType.Local,
saved_only: false,
};
setOptionalAuth(getCommentsForm, req.auth);
@@ -335,6 +343,7 @@ export class Home extends Component {
admins={siteRes.admins}
counts={siteRes.site_view.counts}
online={siteRes.online}
+ showLocal={showLocal(this.isoData)}
/>
)}
{this.state.showTrendingMobile && (
@@ -371,6 +380,7 @@ export class Home extends Component {
admins={siteRes.admins}
counts={siteRes.site_view.counts}
online={siteRes.online}
+ showLocal={showLocal(this.isoData)}
/>
{UserService.Instance.myUserInfo &&
@@ -530,6 +540,7 @@ export class Home extends Component {
@@ -615,10 +626,13 @@ export class Home extends Component {
page: this.state.page,
limit: fetchLimit,
sort: this.state.sort,
- type_: this.state.listingType,
saved_only: false,
auth: authField(false),
};
+ if (this.state.listingType) {
+ getPostsForm.type_ = this.state.listingType;
+ }
+
WebSocketService.Instance.send(wsClient.getPosts(getPostsForm));
} else {
let getCommentsForm: GetComments = {
diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx
index 52546997..30c6e357 100644
--- a/src/shared/components/home/setup.tsx
+++ b/src/shared/components/home/setup.tsx
@@ -64,7 +64,7 @@ export class Setup extends Component {
{!this.state.doneRegisteringUser ? (
this.registerUser()
) : (
-
+
)}
diff --git a/src/shared/components/home/site-form.tsx b/src/shared/components/home/site-form.tsx
index 50797e6f..f3640596 100644
--- a/src/shared/components/home/site-form.tsx
+++ b/src/shared/components/home/site-form.tsx
@@ -1,6 +1,6 @@
import { Component, linkEvent } from "inferno";
import { Prompt } from "inferno-router";
-import { CreateSite, EditSite, Site } from "lemmy-js-client";
+import { CreateSite, EditSite, ListingType, Site } from "lemmy-js-client";
import { i18n } from "../../i18next";
import { WebSocketService } from "../../services";
import {
@@ -11,10 +11,12 @@ import {
} from "../../utils";
import { Spinner } from "../common/icon";
import { ImageUploadForm } from "../common/image-upload-form";
+import { ListingTypeSelect } from "../common/listing-type-select";
import { MarkdownTextArea } from "../common/markdown-textarea";
interface SiteFormProps {
site?: Site; // If a site is given, that means this is an edit
+ showLocal: boolean;
onCancel?(): any;
onEdit?(): any;
}
@@ -39,6 +41,7 @@ export class SiteForm extends Component {
application_question: null,
private_instance: null,
default_theme: null,
+ default_post_listing_type: null,
auth: authField(false),
},
loading: false,
@@ -59,6 +62,9 @@ export class SiteForm extends Component {
this.handleBannerUpload = this.handleBannerUpload.bind(this);
this.handleBannerRemove = this.handleBannerRemove.bind(this);
+ this.handleDefaultPostListingTypeChange =
+ this.handleDefaultPostListingTypeChange.bind(this);
+
if (this.props.site) {
let site = this.props.site;
this.state.siteForm = {
@@ -76,6 +82,7 @@ export class SiteForm extends Component {
application_question: site.application_question,
private_instance: site.private_instance,
default_theme: site.default_theme,
+ default_post_listing_type: site.default_post_listing_type,
auth: authField(false),
};
}
@@ -350,6 +357,21 @@ export class SiteForm extends Component {
+ {this.props.showLocal && (
+
+ )}