Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/webview/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { ActivityIndicator, TouchableOpacity } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { WebView } from "react-native-webview";
import styled from "styled-components/native";

Check warning on line 16 in app/webview/[slug].tsx

View workflow job for this annotation

GitHub Actions / android-check

Using exported name 'styled' as identifier for default import

const webviewUrl =
process.env.EXPO_PUBLIC_WEBVIEW_URL || "https://develop.moadong.com";
Expand Down Expand Up @@ -87,11 +87,11 @@
}
};

const handleNavigateWebview = (slug: string) => {
const handleNavigateWebview = (slug: string, clubId?: string) => {
if (slug.startsWith('club/')) {
const clubId = slug.slice('club/'.length);
if (!clubId) return;
router.push({ pathname: '/club/[id]', params: { id: clubId } });
const slugId = slug.slice('club/'.length);
if (!slugId) return;
router.push({ pathname: '/club/[id]', params: { id: slugId, clubId } });
} else {
router.push({ pathname: '/webview/[slug]', params: { slug } });
}
Expand Down Expand Up @@ -174,6 +174,7 @@
domStorageEnabled={true}
/>
</WebViewWrapper>

</Container>
);
}
Expand Down
4 changes: 2 additions & 2 deletions hooks/use-webview-message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface UseWebViewMessageHandlerOptions {
// 뒤로가기 요청 시 호출
onNavigateBack?: () => void;
// 웹뷰 내 화면 이동 요청 시 호출
onNavigateWebview?: (slug: string) => void;
onNavigateWebview?: (slug: string, clubId?: string) => void;
// 알림 구독 요청 시 호출
onSubscribe?: (clubId: string, clubName?: string) => Promise<void> | void;
// 알림 구독 해제 요청 시 호출
Expand Down Expand Up @@ -36,7 +36,7 @@ export const useWebViewMessageHandler = ({
break;
case WebViewMessageTypes.NAVIGATE_WEBVIEW:
if (message.payload?.slug) {
onNavigateWebview?.(message.payload.slug);
onNavigateWebview?.(message.payload.slug, message.payload.clubId);
}
break;
case WebViewMessageTypes.NOTIFICATION_SUBSCRIBE:
Expand Down
2 changes: 1 addition & 1 deletion types/webview-message.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const WebViewMessageTypes = {

export type WebViewMessage =
| { type: 'NAVIGATE_BACK' }
| { type: 'NAVIGATE_WEBVIEW'; payload: { slug: string } }
| { type: 'NAVIGATE_WEBVIEW'; payload: { slug: string; clubId?: string } }
| { type: 'NOTIFICATION_SUBSCRIBE'; payload: { clubId: string; clubName?: string } }
| { type: 'NOTIFICATION_UNSUBSCRIBE'; payload: { clubId: string } }
| { type: 'SHARE'; payload: { title: string; text: string; url: string } }
Expand Down
12 changes: 7 additions & 5 deletions ui/club-detail/club-detail-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import styled from "styled-components/native";

export default function ClubWebViewScreen() {
const router = useRouter();
const { id, name } = useLocalSearchParams<{ id?: string; name?: string }>();
const { id, name, clubId: objectId } = useLocalSearchParams<{ id?: string; name?: string; clubId?: string }>();
const [isLoading, setIsLoading] = useState(true);
const [hasError, setHasError] = useState(false);
const [showPermissionDialog, setShowPermissionDialog] = useState(false);
Expand All @@ -38,15 +38,17 @@ export default function ClubWebViewScreen() {
const baseUrl = `${cleanUrl}/webview/club/${id}`;

let url = appendSessionId(baseUrl, sessionId);
if (id && isSubscribed(id)) {
const lookupId = typeof objectId === 'string' ? objectId : id;
if (lookupId && isSubscribed(lookupId)) {
url += `&is_subscribed=true`;
}
return url;
}, [id, webviewUrl, sessionId, isSubscribed]);
}, [id, objectId, webviewUrl, sessionId, isSubscribed]);

const subscribed = useMemo(() => {
return id ? isSubscribed(id) : false;
}, [id, isSubscribed]);
const lookupId = typeof objectId === 'string' ? objectId : id;
return lookupId ? isSubscribed(lookupId) : false;
}, [id, objectId, isSubscribed]);

const userAgent = getWebViewUserAgent();

Expand Down
12 changes: 8 additions & 4 deletions ui/home/home-webview-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Constants from 'expo-constants';
import { useRouter } from 'expo-router';
import * as WebBrowser from 'expo-web-browser';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { ActivityIndicator, BackHandler, Platform, View } from 'react-native';
import { ActivityIndicator, BackHandler, Platform, Share, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import {
WebView,
Expand Down Expand Up @@ -91,9 +91,9 @@ export function HomeWebViewScreen({ onError }: HomeWebViewScreenProps) {
case 'NAVIGATE_WEBVIEW':
if (!loaded) break;
if (payload.slug?.startsWith('club/')) {
const clubId = payload.slug.slice('club/'.length);
if (!clubId) break;
router.push({ pathname: '/club/[id]', params: { id: clubId } });
const slugId = payload.slug.slice('club/'.length);
if (!slugId) break;
router.push({ pathname: '/club/[id]', params: { id: slugId, clubId: payload.clubId } });
} else if (payload.slug?.startsWith('promotions/')) {
router.push({ pathname: '/webview/[slug]', params: { slug: 'promotions', path: `/${payload.slug}`, hideHeader: 'true' } });
} else {
Expand All @@ -105,6 +105,10 @@ export function HomeWebViewScreen({ onError }: HomeWebViewScreenProps) {
await WebBrowser.openBrowserAsync(payload.url);
break;

case 'SHARE':
await Share.share({ title: payload.title, message: payload.text, url: payload.url });
break;

case 'REQUEST_APP_VERSION':
sendMessage({
type: 'APP_VERSION',
Expand Down
Loading