From bbd47929f0dc3389dead8894a87972d382536f86 Mon Sep 17 00:00:00 2001
From: Alexander Harding <2166114+aeharding@users.noreply.github.com>
Date: Mon, 18 Mar 2024 21:22:43 -0500
Subject: [PATCH 01/11] Add long press tabs (#1341)
---
src/core/App.tsx | 2 +
src/core/listeners/statusTap.ts | 12 +
.../community/titleSearch/TitleSearch.tsx | 24 +-
src/features/shared/AppHeader.tsx | 53 +---
src/helpers/longPress.ts | 35 ++-
src/routes/TabBar.tsx | 287 ++----------------
src/routes/pages/search/SearchPage.tsx | 23 +-
.../pages/shared/InstanceSidebarPage.tsx | 32 +-
src/routes/tabs/buttons/InboxTabButton.tsx | 26 ++
src/routes/tabs/buttons/PostsTabButton.tsx | 78 +++++
src/routes/tabs/buttons/ProfileTabButton.tsx | 79 +++++
src/routes/tabs/buttons/SearchTabButton.tsx | 34 +++
src/routes/tabs/buttons/SettingsTabButton.tsx | 39 +++
src/routes/tabs/buttons/shared.tsx | 131 ++++++++
14 files changed, 529 insertions(+), 326 deletions(-)
create mode 100644 src/routes/tabs/buttons/InboxTabButton.tsx
create mode 100644 src/routes/tabs/buttons/PostsTabButton.tsx
create mode 100644 src/routes/tabs/buttons/ProfileTabButton.tsx
create mode 100644 src/routes/tabs/buttons/SearchTabButton.tsx
create mode 100644 src/routes/tabs/buttons/SettingsTabButton.tsx
create mode 100644 src/routes/tabs/buttons/shared.tsx
diff --git a/src/core/App.tsx b/src/core/App.tsx
index 16ea32d74f..716bf0c503 100644
--- a/src/core/App.tsx
+++ b/src/core/App.tsx
@@ -39,6 +39,7 @@ import "@ionic/react/css/display.css";
import "./listeners";
import AppUrlListener from "./listeners/AppUrlListener";
import OldInstanceWarning from "./OldInstanceWarning";
+import { ResetStatusTap } from "./listeners/statusTap";
// index.tsx ensures android nav mode resolves before app is rendered
(async () => {
@@ -72,6 +73,7 @@ export default function App() {
diff --git a/src/services/app.ts b/src/services/app.ts
index 37ac8eeeca..0dd84e0b58 100644
--- a/src/services/app.ts
+++ b/src/services/app.ts
@@ -21,12 +21,16 @@ export function defaultServersUntouched() {
async function getConfig() {
if (isNative()) return;
- const response = await fetch("/_config");
+ try {
+ const response = await fetch("/_config");
- const { customServers } = await response.json();
+ const { customServers } = await response.json();
- if (customServers?.length) {
- _customServers = customServers;
+ if (customServers?.length) {
+ _customServers = customServers;
+ }
+ } catch (error) {
+ return; // ignore errors in loading config
}
}
From bdf1f0655f3b4dfe100a25bdd0c29a852784029d Mon Sep 17 00:00:00 2001
From: Alexander Harding <2166114+aeharding@users.noreply.github.com>
Date: Tue, 19 Mar 2024 19:32:21 -0500
Subject: [PATCH 05/11] Fix build warnings (#1346)
---
.../media/gallery/GalleryProvider.tsx | 31 ++++++++++++-------
vite.config.ts | 2 ++
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/features/media/gallery/GalleryProvider.tsx b/src/features/media/gallery/GalleryProvider.tsx
index f865644d4b..b8a0896b2a 100644
--- a/src/features/media/gallery/GalleryProvider.tsx
+++ b/src/features/media/gallery/GalleryProvider.tsx
@@ -12,17 +12,20 @@ import React, {
import GalleryPostActions from "./GalleryPostActions";
import { createPortal } from "react-dom";
import { PostView } from "lemmy-js-client";
-import PhotoSwipeLightbox, { PreparedPhotoSwipeOptions } from "photoswipe";
import { getSafeArea, isAndroid, isNative } from "../../../helpers/device";
-import "photoswipe/style.css";
import { useLocation } from "react-router";
import { StatusBar } from "@capacitor/status-bar";
import { setPostRead } from "../../post/postSlice";
import { useAppDispatch } from "../../../store";
import GalleryMedia from "./GalleryMedia";
import ImageMoreActions from "./ImageMoreActions";
+
+import type { PreparedPhotoSwipeOptions } from "photoswipe";
import type ZoomLevel from "photoswipe/dist/types/slide/zoom-level";
+import PhotoSwipeLightbox from "photoswipe/lightbox";
+
+import "photoswipe/style.css";
interface IGalleryContext {
// used for determining whether page needs to be scrolled up first
@@ -71,14 +74,16 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
useEffect(() => {
if (!lightboxRef.current) return;
- lightboxRef.current.close();
+ lightboxRef.current.pswp?.close();
}, [location.pathname]);
const close = useCallback(() => {
if (!lightboxRef.current) return;
- lightboxRef.current.options.showHideAnimationType = "fade";
- lightboxRef.current.close();
+ if (lightboxRef.current.pswp)
+ lightboxRef.current.pswp.options.showHideAnimationType = "fade";
+
+ lightboxRef.current.pswp?.close();
}, []);
const open = useCallback(
@@ -181,7 +186,7 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
instance.on("tapAction", () => {
if (currZoomLevel !== zoomLevel.min) {
- instance.zoomTo(zoomLevel.min, undefined, 300);
+ instance.pswp?.zoomTo(zoomLevel.min, undefined, 300);
currZoomLevel = zoomLevel.min;
// queueMicrotask, otherwise will be overwritten by internal photoswipe ui toggle
@@ -203,9 +208,13 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
function onZoomChange() {
if (currZoomLevel <= zoomLevel.min) {
- instance.gestures.pswp.element?.classList.add("pswp--ui-visible");
+ instance.pswp?.gestures.pswp.element?.classList.add(
+ "pswp--ui-visible",
+ );
} else {
- instance.gestures.pswp.element?.classList.remove("pswp--ui-visible");
+ instance.pswp?.gestures.pswp.element?.classList.remove(
+ "pswp--ui-visible",
+ );
}
}
@@ -232,7 +241,7 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
});
instance.on("uiRegister", function () {
- instance.ui?.registerElement({
+ instance.pswp?.ui?.registerElement({
appendTo: "root",
onInit: (el) => {
setActionContainer(el);
@@ -315,7 +324,7 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
}
if (instance !== null) {
- instance.close();
+ instance.pswp?.close();
}
};
@@ -339,7 +348,7 @@ export default function GalleryProvider({ children }: GalleryProviderProps) {
// Android back button logic end
// -----------------------------
- instance.init();
+ instance.loadAndOpen(0);
lightboxRef.current = instance;
},
[dispatch],
diff --git a/vite.config.ts b/vite.config.ts
index c16a48adce..0944541b97 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -29,6 +29,7 @@ export default defineConfig({
manifestFilename: "manifest.json",
manifest,
workbox: {
+ maximumFileSizeToCacheInBytes: 2097152 * 2,
runtimeCaching: [
{
handler: "StaleWhileRevalidate",
@@ -48,6 +49,7 @@ export default defineConfig({
// break. This breaks iOS transitions.
// Put everything into one chunk for now.
build: {
+ chunkSizeWarningLimit: 5_000,
rollupOptions: {
output: {
manualChunks: () => "index.js",
From 27c3645bbe269b97e75c17a1afd97a8c1e14657a Mon Sep 17 00:00:00 2001
From: Alexander Harding <2166114+aeharding@users.noreply.github.com>
Date: Wed, 20 Mar 2024 18:44:37 -0500
Subject: [PATCH 06/11] More visible quote fill color (#1351)
---
src/features/shared/markdown/Markdown.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/features/shared/markdown/Markdown.tsx b/src/features/shared/markdown/Markdown.tsx
index 0b34e8a557..3fa1526c66 100644
--- a/src/features/shared/markdown/Markdown.tsx
+++ b/src/features/shared/markdown/Markdown.tsx
@@ -26,7 +26,8 @@ const markdownCss = css`
blockquote {
padding-left: 0.5rem;
- border-left: 3px solid var(--ion-color-light);
+ border-left: 3px solid
+ var(--ion-border-color, var(--ion-background-color-step-250, #c8c7cc));
margin-left: 0;
}
From aefe74d64974c0887ab5b11dd5006c8f06921a5a Mon Sep 17 00:00:00 2001
From: Alexander Harding <2166114+aeharding@users.noreply.github.com>
Date: Wed, 20 Mar 2024 21:22:48 -0500
Subject: [PATCH 07/11] Make instance not tappable in large feed view (#1350)
Resolves #1142
---
src/features/labels/Handle.tsx | 19 +++---
src/features/labels/links/CommunityLink.tsx | 42 ++++++++------
src/features/labels/links/PersonLink.tsx | 61 ++++++++++++--------
src/features/labels/links/shared.ts | 14 ++++-
src/features/post/inFeed/large/LargePost.tsx | 2 +
5 files changed, 87 insertions(+), 51 deletions(-)
diff --git a/src/features/labels/Handle.tsx b/src/features/labels/Handle.tsx
index 279846fa05..ac8d15251c 100644
--- a/src/features/labels/Handle.tsx
+++ b/src/features/labels/Handle.tsx
@@ -12,13 +12,14 @@ interface HandleProps {
item: Pick