Skip to content

Commit

Permalink
Merge branch 'persist-share-as-image-choices' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sharunkumar committed Aug 11, 2024
2 parents 62940bd + f4db7a2 commit 92ab40d
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 47 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*.{js,ts,jsx,tsx,yaml,json}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,32 @@ Native apps can be great, but we believe in the strengths of the web. Why use a

## Deployment

### Official Deployment
### Ecosystem

**For most users,** we recommend the native app available in the stores:

<a href="https://apps.apple.com/us/app/voyager-for-lemmy/id6451429762"><img src="public/badges/ios.svg" height="45"></a>&nbsp;&nbsp;
<a href="https://play.google.com/store/apps/details?id=app.vger.voyager"><img src="public/badges/play.svg" height="45"></a>&nbsp;&nbsp;<a href="https://f-droid.org/en/packages/app.vger.voyager/"><img src="public/badges/fdroid.png" height="45"></a>

The Voyager team maintains a deployment at:
However, if you prefer using the Progressive Web App, there are a number of folks that host it:

| Country | URL | Description | Contact/Privacy |
| ---------------- | -------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------- |
| 🇺🇸 Virginia, USA | [vger.app](https://vger.app) | ✅ Official Voyager PWA instance | [➡️](https://vger.social/u/aeharding) |
| 🇫🇮 Finland | [m.lemmy.world](https://m.lemmy.world) | Voyager hosted by the mastodon.world team. | [➡️](https://mastodon.world/about) |
| 🇸🇬 Singapore | [v.opnxng.com](https://v.opnxng.com) | Voyager hosted by Opnxng in Singapore. | [➡️](https://about.opnxng.com) |
| 🇲🇽 Mexico | [voyager.nohost.network](https://voyager.nohost.network) | Voyager hosted by Nohost in Mexico. | [➡️](https://nohost.network) |
| 🇺🇸 USA | [vger.thesanewriter.com](https://vger.thesanewriter.com) | Voyager hosted by the lemmy.thesanewriter.com team. | [➡️](https://lemmy.thesanewriter.com/legal) |
| 🇺🇸 Oregon, USA | [m.lemmy.today](https://m.lemmy.today) | A fast, general purpose instance located in Oregon, USA | [➡️](https://lemmy.today) |
| 🇫🇷 France | [v.lemmy.dbzer0.com](https://v.lemmy.dbzer0.com) | Be Weird, Download a Car, Generate Art, Screw Copyrights | [➡️](https://lemmy.dbzer0.com) |
| ? | [v.programming.dev](https://v.programming.dev) | A collection of programming communities | [➡️](https://legal.programming.dev) |
| 🇺🇸 Oregon, USA | [v.lemmy.eco.br](https://v.lemmy.eco.br) | A fast, general purpose instance located in Oregon, USA | [➡️](https://lemmy.eco.br) |
| 🇩🇪 Germany | [v.lemy.lol](https://v.lemy.lol) | Long-term, general purpose Lemmy instance. | [➡️](https://lemy.lol) |
| 🇵🇹 Portugal | [voyager.slrpnk.net](https://voyager.slrpnk.net) | Sustainable future interconnected with nature and community. | [➡️](https://slrpnk.net) |
| ? | [app.thelemmy.club](https://app.thelemmy.club) | A general Lemmy instance for all! | [➡️](https://thelemmy.club) |
| ? | [m.lemdro.id](https://m.lemdro.id) | Fully open source instance with incredible transparency. | [➡️](https://lemdro.id) |

- 🐭 Production: [vger.app](https://vger.app)
> **Note**: Community deployments are **NOT** maintained by the Voyager team. They may not be synced with Voyager's source code. Please do your own research about the host servers before using them.
### Self-Host

Expand Down Expand Up @@ -132,15 +153,6 @@ Optionally, you can serve a custom list of instance(s) in the `/_config` endpoin

For production, serve `index.html` with `Cache-Control: no-cache` and `/assets` with a long cache period (files in assets are immutable)

### Ecosystem

- 🇫🇮 [m.lemmy.world](https://m.lemmy.world) - Voyager hosted by the mastodon.world team. [Contact/privacy](https://mastodon.world/about)
- 🇸🇬 [v.opnxng.com](https://v.opnxng.com) - Voyager hosted by Opnxng in Singapore. [Contact/privacy](https://about.opnxng.com)
- 🇲🇽 [voyager.nohost.network](https://voyager.nohost.network) - Voyager hosted by Nohost in Mexico. [Contact/privacy](https://nohost.network)
- 🇺🇸 [vger.thesanewriter.com](https://vger.thesanewriter.com) - Voyager hosted by the lemmy.thesanewriter.com team. [Contact/privacy](https://lemmy.thesanewriter.com/legal)

> **Note**: Community deployments are **NOT** maintained by the Voyager team. They may not be synced with Voyager's source code. Please do your own research about the host servers before using them.
## 💖 Sponsors

If you're enjoying Voyager, you can sponsor it:
Expand Down
11 changes: 11 additions & 0 deletions src/features/feed/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { ListingType } from "lemmy-js-client";
import { getFeedUrlName } from "../community/mod/ModActions";

type InternalFeedType =
| "PostsSearch"
| "CommentsSearch"
| "CommunitiesSearch"
| "CommunitiesExplore";

export type AnyFeed =
| {
remoteCommunityHandle: string;
}
| {
listingType: ListingType;
}
| {
internal: InternalFeedType;
};

export function serializeFeedName(feed: AnyFeed): string {
Expand All @@ -15,6 +24,8 @@ export function serializeFeedName(feed: AnyFeed): string {
return feed.remoteCommunityHandle; // always contains @ - will never overlap with getFeedUrlName
case "listingType" in feed:
return getFeedUrlName(feed.listingType);
case "internal" in feed:
return `@@voyager_${feed.internal}`;
default:
return feed;
}
Expand Down
3 changes: 1 addition & 2 deletions src/features/labels/links/CommunityLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const StyledItemIcon = styled(ItemIcon)`
const SubscribedIcon = styled(IonIcon)`
color: var(--ion-color-danger);
vertical-align: middle;
font-size: 0.85em;
margin-bottom: 1px;
margin-left: 2px;
Expand Down Expand Up @@ -163,7 +162,7 @@ const onStart: LongPressOptions["onStart"] = (e) => {
function useShowSubscribedIcon() {
const feedEnabled = useContext(ShowSubscribedIconContext);
const subscribedIcon = useAppSelector(
(state) => state.settings.general.subscribedIcon,
(state) => state.settings.appearance.posts.subscribedIcon,
);

switch (subscribedIcon) {
Expand Down
15 changes: 3 additions & 12 deletions src/features/post/appearance/appearanceSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PayloadAction, createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { ListingType } from "lemmy-js-client";
import { PostAppearanceType, db } from "../../../services/db";
import { serializeFeedName } from "../../feed/helpers";
import { AnyFeed, serializeFeedName } from "../../feed/helpers";

interface PostAppearanceState {
/**
Expand All @@ -21,7 +20,7 @@ export const postAppearanceSlice = createSlice({
setPostAppeartance: (
state,
action: PayloadAction<{
feed: FeedSortFeed;
feed: AnyFeed;
postAppearance: PostAppearanceType;
}>,
) => {
Expand All @@ -47,17 +46,9 @@ export const { setPostAppeartance } = postAppearanceSlice.actions;

export default postAppearanceSlice.reducer;

export type FeedSortFeed =
| {
remoteCommunityHandle: string;
}
| {
listingType: ListingType;
};

export const getPostAppearance = createAsyncThunk(
"postAppearance/getPostAppearance",
async (feed: FeedSortFeed) => {
async (feed: AnyFeed) => {
const feedName = serializeFeedName(feed);
const postAppearance =
(await db.getSetting("post_appearance_type", {
Expand Down
4 changes: 3 additions & 1 deletion src/features/settings/appearance/posts/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EmbedExternalMedia from "./EmbedExternalMedia";
import AlwaysShowAuthor from "./AlwaysShowAuthor";
import RememberType from "./RememberType";
import CommunityAtTop from "./CommunityAtTop";
import SubscribedIcon from "./SubscribedIcon";

export default function Posts() {
return (
Expand All @@ -20,10 +21,11 @@ export default function Posts() {
<RememberType />
<BlurNsfw />
<CommunityAtTop />
<EmbedCrossposts />
<EmbedExternalMedia />
<ShowCommunityIcons />
<SubscribedIcon />
<AlwaysShowAuthor />
<EmbedCrossposts />
</IonList>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SettingSelector from "../../shared/SettingSelector";

export default function SubscribedIcon() {
const subscribedIcon = useAppSelector(
(state) => state.settings.general.subscribedIcon,
(state) => state.settings.appearance.posts.subscribedIcon,
);

return (
Expand Down
2 changes: 0 additions & 2 deletions src/features/settings/general/other/Other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import OpenNativeApps from "./OpenNativeApps";
import ClearCache from "./ClearCache";
import BackupSettings from "./backup/BackupSettings";
import Thumbnailinator from "./Thumbnailinator";
import SubscribedIcon from "./SubscribedIcon";

export default function Other() {
return (
Expand All @@ -25,7 +24,6 @@ export default function Other() {
<Haptics />
<NoSubscribedInFeed />
<Thumbnailinator />
<SubscribedIcon />
<ClearCache />
<BackupSettings />
</IonList>
Expand Down
10 changes: 5 additions & 5 deletions src/features/settings/settingsSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ interface SettingsState {
embedExternalMedia: boolean;
alwaysShowAuthor: boolean;
communityAtTop: boolean;
subscribedIcon: ShowSubscribedIcon;
};
large: {
showVotingButtons: boolean;
Expand Down Expand Up @@ -138,7 +139,6 @@ interface SettingsState {
defaultFeed: DefaultFeedType | undefined;
noSubscribedInFeed: boolean;
thumbnailinatorEnabled: boolean;
subscribedIcon: ShowSubscribedIcon;
};
blocks: {
keywords: string[];
Expand Down Expand Up @@ -167,6 +167,7 @@ export const initialState: SettingsState = {
embedExternalMedia: true,
alwaysShowAuthor: false,
communityAtTop: false,
subscribedIcon: OShowSubscribedIcon.Never,
},
large: {
showVotingButtons: false,
Expand Down Expand Up @@ -226,7 +227,6 @@ export const initialState: SettingsState = {
defaultFeed: undefined,
noSubscribedInFeed: false,
thumbnailinatorEnabled: true,
subscribedIcon: OShowSubscribedIcon.Never,
},
blocks: {
keywords: [],
Expand Down Expand Up @@ -543,7 +543,7 @@ export const appearanceSlice = createSlice({
db.setSetting("prefer_native_apps", action.payload);
},
setSubscribedIcon(state, action: PayloadAction<ShowSubscribedIcon>) {
state.general.subscribedIcon = action.payload;
state.appearance.posts.subscribedIcon = action.payload;

db.setSetting("subscribed_icon", action.payload);
},
Expand Down Expand Up @@ -805,6 +805,8 @@ export const fetchSettingsFromDatabase = createAsyncThunk<SettingsState>(
initialState.appearance.posts.alwaysShowAuthor,
communityAtTop:
community_at_top ?? initialState.appearance.posts.communityAtTop,
subscribedIcon:
subscribed_icon ?? initialState.appearance.posts.subscribedIcon,
},
large: {
showVotingButtons:
Expand Down Expand Up @@ -906,8 +908,6 @@ export const fetchSettingsFromDatabase = createAsyncThunk<SettingsState>(
thumbnailinatorEnabled:
thumbnailinator_enabled ??
initialState.general.thumbnailinatorEnabled,
subscribedIcon:
subscribed_icon ?? initialState.general.subscribedIcon,
},
blocks: {
keywords: filtered_keywords ?? initialState.blocks.keywords,
Expand Down
2 changes: 1 addition & 1 deletion src/features/share/asImage/DefaultPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const defaultPreferences: ShareAsImagePreferences = {
hideCommunity: false,
},
comment: {
includePostText: false,
includePostContent: false,
includePostDetails: false,
allParentComments: false,
},
Expand Down
12 changes: 6 additions & 6 deletions src/features/share/asImage/ShareAsImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {

const {
shareAsImagePreferences: {
comment: { includePostText, includePostDetails, allParentComments },
comment: { includePostContent, includePostDetails, allParentComments },
common: { hideUsernames, watermark },
post: { hideCommunity },
},
Expand Down Expand Up @@ -243,7 +243,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
watermark,
hideUsernames,
hideCommunity,
includePostText,
includePostContent,
includePostDetails,
allParentComments,
]);
Expand Down Expand Up @@ -329,14 +329,14 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
{includePostDetails && hasPostBody ? (
<IonItem>
<IonToggle
checked={includePostText}
checked={includePostContent}
onIonChange={({ detail: { checked } }) =>
setShareAsImagePreferences({
comment: { includePostText: checked },
comment: { includePostContent: checked },
})
}
>
Include Post Text
Include Post Content
</IonToggle>
</IonItem>
) : undefined}
Expand Down Expand Up @@ -430,7 +430,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
<PostHeader
className={!("comment" in data) ? hideBottomBorderCss : ""}
post={data.post}
showPostText={includePostText}
showPostText={includePostContent}
showPostActions={false}
constrainHeight={false}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/features/share/asImage/ShareAsImagePreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ShareAsImagePreferences {
};
comment: {
includePostDetails: boolean;
includePostText: boolean;
includePostContent: boolean;
allParentComments: boolean;
};
}
Expand All @@ -39,8 +39,8 @@ const { reducer, actions } = createSlice({
state.post.hideCommunity =
post?.hideCommunity ?? state.post.hideCommunity;

state.comment.includePostText =
comment?.includePostText ?? state.comment.includePostText;
state.comment.includePostContent =
comment?.includePostContent ?? state.comment.includePostContent;
state.comment.includePostDetails =
comment?.includePostDetails ?? state.comment.includePostDetails;
state.comment.allParentComments =
Expand Down
6 changes: 5 additions & 1 deletion src/routes/pages/search/CommunitiesResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default function CommunitiesResultsPage({
}: CommunitiesResultsPageProps) {
const buildGeneralBrowseLink = useBuildGeneralBrowseLink();
const client = useClient();
const [sort, setSort] = useFeedSort("posts", undefined, "TopAll");
const [sort, setSort] = useFeedSort(
"posts",
{ internal: search ? "CommunitiesSearch" : "CommunitiesExplore" },
"TopAll",
);
const [listingType, setListingType] = useState<ListingType>("All");

const fetchFn: FetchFn<CommunityView> = useCallback(
Expand Down
4 changes: 3 additions & 1 deletion src/routes/pages/search/results/SearchFeedResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default function SearchFeedResultsPage({
}>();
const buildGeneralBrowseLink = useBuildGeneralBrowseLink();
const client = useClient();
const [sort, setSort] = useFeedSort("posts");
const [sort, setSort] = useFeedSort("posts", {
internal: `${type}Search`,
});

const search = decodeURIComponent(_encodedSearch);

Expand Down

0 comments on commit 92ab40d

Please sign in to comment.