Skip to content

Commit

Permalink
Merge Release 1.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sharunkumar committed Dec 4, 2023
2 parents edf3d59 + 31f4d54 commit 9f0ab1d
Show file tree
Hide file tree
Showing 49 changed files with 785 additions and 459 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "app.vger.voyager"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 183
versionName "1.27.0"
versionCode 184
versionName "1.28.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 2 additions & 2 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.27.0</string>
<string>1.28.0</string>
<key>CFBundleVersion</key>
<string>183</string>
<string>184</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "voyager",
"description": "A progressive webapp Lemmy client",
"private": true,
"version": "1.27.0",
"version": "1.28.0",
"type": "module",
"packageManager": "pnpm@8.9.2+sha256.8d62573d93061f2722b7b48c9739e96cd4603c3ab153bc81c619dcb9861a214e",
"scripts": {
Expand Down Expand Up @@ -31,6 +31,7 @@
"vite-express": "^0.11.0"
},
"devDependencies": {
"@aeharding/modern-screenshot": "^4.5.0",
"@capacitor-community/app-icon": "^4.1.1",
"@capacitor/android": "5.2.3",
"@capacitor/app": "^5.0.6",
Expand All @@ -53,7 +54,6 @@
"@ionic/core": "npm:voyager-ionic-core@^7.5.5",
"@ionic/react": "7.5.8-dev.11701383555.17254408",
"@ionic/react-router": "7.5.8-dev.11701383555.17254408",
"@justfork/html-to-image": "^1.21.5",
"@reduxjs/toolkit": "^1.9.7",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions src/TabbedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import CommentsPage from "./pages/shared/CommentsPage";
import ModlogPage from "./pages/shared/ModlogPage";
import ModqueuePage from "./pages/shared/ModqueuePage";
import TabBar from "./TabBar";
import { isInstalled } from "./helpers/device";
import { getBaseRoute } from "./features/community/list/CommunitiesListRedirectBootstrapper";

export default function TabbedRoutes() {
const ready = useAppSelector((state) => state.settings.ready);
Expand Down Expand Up @@ -196,6 +198,12 @@ export default function TabbedRoutes() {

if (!ready) return;

const redirectRoute = (() => {
if (isInstalled()) return ""; // redirect to be handled by <CommunitiesListRedirectBootstrapper />

return getBaseRoute(!!iss, defaultFeed);
})();

return (
<PageContextProvider value={pageContextValue}>
<GalleryProvider>
Expand All @@ -207,13 +215,7 @@ export default function TabbedRoutes() {
<Route exact path="/">
{!iss || defaultFeed ? (
<Redirect
to={`/posts/${iss ?? getDefaultServer()}${
iss
? getPathForFeed(
defaultFeed || { type: ODefaultFeedType.Home },
)
: "/all"
}`}
to={`/posts/${iss ?? getDefaultServer()}${redirectRoute}`}
push={false}
/>
) : (
Expand Down Expand Up @@ -377,7 +379,7 @@ export default function TabbedRoutes() {
);
}

function getPathForFeed(defaultFeed: DefaultFeedType): string {
export function getPathForFeed(defaultFeed: DefaultFeedType): string {
switch (defaultFeed.type) {
case ODefaultFeedType.All:
return "/all";
Expand Down
18 changes: 14 additions & 4 deletions src/features/auth/PageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ interface IPageContext {

presentSelectText: (text: string) => void;

presentShareAsImage: (comment: CommentView, comments: CommentView[]) => void;
presentShareAsImage: (
post: PostView,
comment?: CommentView,
comments?: CommentView[],
) => void;
}

export const PageContext = createContext<IPageContext>({
Expand Down Expand Up @@ -100,11 +104,17 @@ export function PageContextProvider({ value, children }: PageContextProvider) {
}, [jwt, presentLogin, value.pageRef]);

const presentShareAsImage = useCallback(
(comment: CommentView, comments: CommentView[]) => {
(post: PostView, comment?: CommentView, comments?: CommentView[]) => {
shareAsImageDataRef.current = {
comment,
comments,
post,
};
if (comment && comments) {
shareAsImageDataRef.current = {
...shareAsImageDataRef.current,
comment,
comments,
};
}
presentShareAsImageModal({
cssClass: "save-as-image-modal",
initialBreakpoint: 1,
Expand Down
10 changes: 8 additions & 2 deletions src/features/comment/CommentEllipsis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export default function MoreActions({
const [presentSecondaryActionSheet] = useIonActionSheet();
const collapseRootComment = useCollapseRootComment(commentView, rootIndex);

const post = useAppSelector(
(state) => state.post.postById[commentView.post.id],
);

const commentById = useAppSelector((state) => state.comment.commentById);

const router = useOptimizedIonRouter();
Expand Down Expand Up @@ -272,8 +276,10 @@ export default function MoreActions({
icon: cameraOutline,
handler: () => {
const comments = getComments();
if (!comments) return;
presentShareAsImage(commentView, comments);

if (!comments || !post || post === "not-found") return;

presentShareAsImage(post, commentView, comments);
},
}
: undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { useAppSelector } from "../../../store";
import { jwtIssSelector } from "../../auth/authSlice";
import { useRef, useState } from "react";
import {
TransitionOptions,
createAnimation,
iosTransitionAnimation,
mdTransitionAnimation,
useIonViewDidEnter,
} from "@ionic/react";
import { getPathForFeed } from "../../../TabbedRoutes";
import { DefaultFeedType, ODefaultFeedType } from "../../../services/db";
import { useBuildGeneralBrowseLink } from "../../../helpers/routes";
import { isInstalled } from "../../../helpers/device";
import styled from "@emotion/styled";
import { useOptimizedIonRouter } from "../../../helpers/useOptimizedIonRouter";

const LoadingOverlay = styled.div`
background: var(--ion-background-color);
position: fixed;
inset: 0;
z-index: 1000;
`;

/**
* This component redirects after the Communities List is mounted,
* for installed apps only.
*
* This improves user experience by always allowing swipe back.
*
* Note: This will become unecessary with the resolution of
* https://github.com/ionic-team/ionic-framework/issues/27892
*/
export default function CommunitiesListRedirectBootstrapper() {
const buildGeneralBrowseLink = useBuildGeneralBrowseLink();
const router = useOptimizedIonRouter();
const [bootstrapped, setBootstrapped] = useState(false);

const defaultFeed = useAppSelector(
(state) => state.settings.general.defaultFeed,
);
const iss = useAppSelector(jwtIssSelector);
const firstEnter = useRef(true);

useIonViewDidEnter(() => {
if (!firstEnter.current) return;
firstEnter.current = false;

if (!isInstalled()) return;

const baseRoute = getBaseRoute(!!iss, defaultFeed);

// user set default page = communities list. We're already there.
if (!baseRoute) {
setBootstrapped(true);
return;
}

requestAnimationFrame(() => {
router.push(
buildGeneralBrowseLink(baseRoute),
"forward",
"push",
undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(baseEl: any, opts: TransitionOptions) => {
// Do not animate into view
if (opts.direction === "forward") return createAnimation();

return opts.mode === "ios"
? iosTransitionAnimation(baseEl, opts)
: mdTransitionAnimation(baseEl, opts);
},
);

requestAnimationFrame(() => setBootstrapped(true));
});
});

if (!isInstalled() || bootstrapped) return null;
return <LoadingOverlay />;
}

export function getBaseRoute(
loggedIn: boolean,
defaultFeed: DefaultFeedType | undefined,
): string {
if (loggedIn)
return getPathForFeed(defaultFeed || { type: ODefaultFeedType.Home });

return "/all";
}
8 changes: 6 additions & 2 deletions src/features/labels/links/CommunityLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getHandle } from "../../../helpers/lemmy";
import { useBuildGeneralBrowseLink } from "../../../helpers/routes";
import { Community, SubscribedType } from "lemmy-js-client";
import Handle from "../Handle";
import { StyledLink } from "./shared";
import { StyledLink, hideCss } from "./shared";
import ItemIcon from "../img/ItemIcon";
import { css } from "@emotion/react";
import { useIonActionSheet } from "@ionic/react";
Expand All @@ -14,6 +14,8 @@ import {
tabletPortraitOutline,
} from "ionicons/icons";
import useCommunityActions from "../../community/useCommunityActions";
import { useContext } from "react";
import { ShareImageContext } from "../../share/asImage/ShareAsImage";

interface CommunityLinkProps {
community: Community;
Expand All @@ -34,6 +36,7 @@ export default function CommunityLink({
const [present] = useIonActionSheet();

const handle = getHandle(community);
const { hideCommunity } = useContext(ShareImageContext);

const { isSubscribed, isBlocked, subscribe, block, sidebar } =
useCommunityActions(community, subscribed);
Expand Down Expand Up @@ -83,9 +86,10 @@ export default function CommunityLink({
to={buildGeneralBrowseLink(`/c/${handle}`)}
onClick={(e) => e.stopPropagation()}
className={className}
css={hideCommunity ? hideCss : undefined}
{...bind()}
>
{showIcon && (
{showIcon && !hideCommunity && (
<ItemIcon
item={community}
size={24}
Expand Down
11 changes: 2 additions & 9 deletions src/features/labels/links/PersonLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from "@emotion/styled";
import { useBuildGeneralBrowseLink } from "../../../helpers/routes";
import { Person } from "lemmy-js-client";
import Handle from "../Handle";
import { StyledLink } from "./shared";
import { StyledLink, hideCss } from "./shared";
import { useAppSelector } from "../../../store";
import { OInstanceUrlDisplayMode } from "../../../services/db";
import AgeBadge from "./AgeBadge";
Expand Down Expand Up @@ -33,14 +33,7 @@ const PersonLinkEl = styled(StyledLink, {
${({ hideUsername }) =>
hideUsername &&
css`
position: relative;
&:after {
content: "";
position: absolute;
inset: 0;
background: var(--ion-color-step-150, #ccc);
}
${hideCss}
`}
`;

Expand Down
12 changes: 12 additions & 0 deletions src/features/labels/links/shared.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import { Link } from "react-router-dom";

Expand All @@ -7,3 +8,14 @@ export const StyledLink = styled(Link)`
font-weight: 500;
white-space: nowrap;
`;

export const hideCss = css`
position: relative;
&:after {
content: "";
position: absolute;
inset: 0;
background: var(--ion-color-step-150, #ccc);
}
`;
Loading

0 comments on commit 9f0ab1d

Please sign in to comment.