diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..0fbc0795 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +EXPO_PUBLIC_WRITE_DEBUG=1 \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..89b6a0c3 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +EXPO_PUBLIC_WRITE_DEBUG=0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6dc107d8..d5a950b9 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,5 @@ credentials.json .ruby-lsp modules/hls-downloader/android/build streamyfin-4fec1-firebase-adminsdk.json -.env \ No newline at end of file +.env +.env.local \ No newline at end of file diff --git a/app/(auth)/(tabs)/(home)/settings/logs/page.tsx b/app/(auth)/(tabs)/(home)/settings/logs/page.tsx index 54bf1b78..4a42f211 100644 --- a/app/(auth)/(tabs)/(home)/settings/logs/page.tsx +++ b/app/(auth)/(tabs)/(home)/settings/logs/page.tsx @@ -1,12 +1,17 @@ import { Text } from "@/components/common/Text"; -import {LogLevel, useLog} from "@/utils/log"; +import {LogLevel, useLog, writeErrorLog} from "@/utils/log"; import { useTranslation } from "react-i18next"; import {ScrollView, TouchableOpacity, View} from "react-native"; import Collapsible from "react-native-collapsible"; -import React, {useMemo, useState} from "react"; +import React, {useCallback, useEffect, useMemo, useState} from "react"; import {FilterButton} from "@/components/filters/FilterButton"; +import {useNavigation} from "expo-router"; +import * as FileSystem from 'expo-file-system'; +import * as Sharing from 'expo-sharing'; +import {Loader} from "@/components/Loader"; export default function page() { + const navigation = useNavigation(); const { logs } = useLog(); const { t } = useTranslation(); @@ -18,6 +23,7 @@ export default function page() { maxHeight: 300 } + const [loading, setLoading] = useState(false) const [state, setState] = useState>({}) const [order, setOrder] = useState<"asc" | "desc">("desc"); @@ -31,6 +37,34 @@ export default function page() { [logs, order, levels] ) + // Sharing it as txt while its formatted allows us to share it with many more applications + const share = useCallback(async () => { + const uri = FileSystem.documentDirectory + "logs.txt" + + setLoading(true) + FileSystem.writeAsStringAsync(uri, JSON.stringify(filteredLogs)) + .then(() => { + setLoading(false) + Sharing.shareAsync(uri, {mimeType: "txt", UTI: "txt"}) + }) + .catch((e) => writeErrorLog("Something went wrong attempting to export", e)) + .finally(() => setLoading(false)) + }, [filteredLogs]) + + useEffect(() => { + navigation.setOptions({ + headerRight: () => ( + loading + ? + : ( + + Export + + ) + ), + }); + }, [share, loading]); + return ( <> @@ -86,7 +120,9 @@ export default function page() { {log.data && ( <> - {t("home.settings.logs.click_for_more_info")} + {!state[log.timestamp] && ( + {t("home.settings.logs.click_for_more_info")} + )} diff --git a/bun.lock b/bun.lock index c72cc71f..36b3d849 100644 --- a/bun.lock +++ b/bun.lock @@ -44,6 +44,7 @@ "expo-router": "~4.0.17", "expo-screen-orientation": "~8.0.4", "expo-sensors": "~14.0.2", + "expo-sharing": "~13.0.1", "expo-splash-screen": "~0.29.22", "expo-status-bar": "~2.0.1", "expo-system-ui": "~4.0.8", @@ -1201,6 +1202,8 @@ "expo-sensors": ["expo-sensors@14.0.2", "", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "expo": "*", "react-native": "*" } }, "sha512-nCb1Q3ctb0oVTZ9p6eFmQ2fINa6KoxXXIhagPpdN0qR82p00YosP27IuyxjVB3fnCJFeC4TffNxNjBxwAUk+nA=="], + "expo-sharing": ["expo-sharing@13.0.1", "", { "peerDependencies": { "expo": "*" } }, "sha512-qych3Nw65wlFcnzE/gRrsdtvmdV0uF4U4qVMZBJYPG90vYyWh2QM9rp1gVu0KWOBc7N8CC2dSVYn4/BXqJy6Xw=="], + "expo-splash-screen": ["expo-splash-screen@0.29.22", "", { "dependencies": { "@expo/prebuild-config": "^8.0.27" }, "peerDependencies": { "expo": "*" } }, "sha512-f+bPpF06bqiuW1Fbrd3nxeaSsmTVTBEKEYe3epYt4IE6y4Ulli3qEUamMLlRQiDGuIXPU6zQlscpy2mdBUI5cA=="], "expo-status-bar": ["expo-status-bar@2.0.1", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-AkIPX7jWHRPp83UBZ1iXtVvyr0g+DgBVvIXTtlmPtmUsm8Vq9Bb5IGj86PW8osuFlgoTVAg7HI/+Ok7yEYwiRg=="], diff --git a/eas.json b/eas.json index fb5e37e1..a0282a7b 100644 --- a/eas.json +++ b/eas.json @@ -11,7 +11,7 @@ "buildType": "apk" }, "env": { - "DEBUG": "1" + "EXPO_PUBLIC_WRITE_DEBUG": "1" } }, "development_tv": { @@ -22,13 +22,13 @@ }, "env": { "EXPO_TV": "1", - "DEBUG": "1" + "EXPO_PUBLIC_WRITE_DEBUG": "1" } }, "preview": { "distribution": "internal", "env": { - "DEBUG": "1" + "EXPO_PUBLIC_WRITE_DEBUG": "1" } }, "development-simulator": { @@ -38,7 +38,7 @@ "simulator": true }, "env": { - "DEBUG": "1" + "EXPO_PUBLIC_WRITE_DEBUG": "1" } }, "production": { diff --git a/package.json b/package.json index bc3b75d6..85bf9923 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "submodule-reload": "git submodule update --init --remote --recursive", "clean": "echo y | expo prebuild --clean", "start": "bun run submodule-reload && expo start", - "ios": "EXPO_TV=0 DEBUG=1 expo run:ios", - "ios:tv": "EXPO_TV=1 DEBUG=1 expo run:ios", - "android": "EXPO_TV=0 DEBUG=1 expo run:android", - "android:tv": "EXPO_TV=1 DEBUG=1 expo run:android", + "ios": "EXPO_TV=0 expo run:ios", + "ios:tv": "EXPO_TV=1 expo run:ios", + "android": "EXPO_TV=0 expo run:android", + "android:tv": "EXPO_TV=1 expo run:android", "prebuild": "EXPO_TV=0 bun run clean", "prebuild:tv": "EXPO_TV=1 bun run clean", "prepare": "husky", @@ -56,6 +56,7 @@ "expo-router": "~4.0.17", "expo-screen-orientation": "~8.0.4", "expo-sensors": "~14.0.2", + "expo-sharing": "~13.0.1", "expo-splash-screen": "~0.29.22", "expo-status-bar": "~2.0.1", "expo-system-ui": "~4.0.8", diff --git a/utils/log.tsx b/utils/log.tsx index debb626a..5b1a29a3 100644 --- a/utils/log.tsx +++ b/utils/log.tsx @@ -63,7 +63,7 @@ export const writeInfoLog = (message: string, data?: any) => export const writeErrorLog = (message: string, data?: any) => writeToLog("ERROR", message, data); export const writeDebugLog = (message: string, data?: any) => { - if (process.env.DEBUG === "1") { + if (process.env.EXPO_PUBLIC_WRITE_DEBUG === "1") { writeToLog("DEBUG", message, data); } }