Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: in app playStore update #392

Merged
merged 9 commits into from
Apr 25, 2024
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
Binary file modified .yarn/install-state.gz
Binary file not shown.
15 changes: 15 additions & 0 deletions __tests__/mediafetch/ytbChannel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// GMHikaru
import { fetchYTIChannel } from '../../src/utils/mediafetch/ytbchannel';
import fetcher from '../../src/utils/mediafetch/bilivideo';
test('bilivideo', async () => {
const result = await fetchYTIChannel('@MioriCelesta');
console.log(result);
return;
const content = await fetcher.regexFetch({
reExtracted: fetcher.regexSearchMatch.exec(
'https://www.bilibili.com/video/BV1KW4y1p7oT/?spm_id_from=333.999.0.0'
)!,
});
// console.log(content);
expect(content?.songList[0]?.id).not.toBeNull();
});
3 changes: 1 addition & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ dependencies {

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation("com.facebook.react:flipper-integration")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
Expand Down
20 changes: 0 additions & 20 deletions android/app/src/release/java/com/example/ReactNativeFlipper.java

This file was deleted.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
ndkVersion = "25.1.8937393"

ffmpegKitPackage = "audio"
kotlinVersion = "1.8.0"
kotlinVersion = "1.9.20"
}
repositories {
mavenLocal()
Expand Down
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module.exports = api => {
},
],
'react-native-reanimated/plugin',
[
'@babel/plugin-syntax-import-attributes',
{
deprecatedAssertSyntax: true,
},
],
],
};
}
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const esModules = [
'decode-uri-component',
'libmuse',
'lodash',
'youtubei',
'jintr',
].join('|');

const config = {
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@shopify/flash-list": "^1.6.4",
"@shopify/react-native-skia": "1.2.3",
"axios": "^1.6.8",
"babel-plugin-transform-remove-console": "^6.9.4",
"base-64": "^1.0.0",
"base64-js": "^1.5.1",
"big-integer": "^1.6.52",
Expand Down Expand Up @@ -74,38 +73,38 @@
"postinstall-postinstall": "^2.1.0",
"qs": "^6.12.1",
"react": "18.2.0",
"react-i18next": "^14.1.0",
"react-i18next": "^14.1.1",
"react-native": "0.73.7",
"react-native-app-auth": "^7.1.3",
"react-native-background-timer": "git+https://github.com/lovegaoshi/react-native-background-timer.git",
"react-native-blob-jsi-helper": "^0.3.1",
"react-native-blob-util": "^0.19.9",
"react-native-device-info": "^10.13.2",
"react-native-draggable-flatlist": "^4.0.1",
"react-native-gesture-handler": "2.16.0",
"react-native-get-random-values": "^1.11.0",
"react-native-lyric": "git+https://github.com/lovegaoshi/react-native-lyric.git#dev",
"react-native-pager-view": "^6.3.0",
"react-native-pager-view": "^6.3.1",
"react-native-paper": "^5.12.3",
"react-native-qrcode-svg": "^6.3.0",
"react-native-reanimated": "^3.8.1",
"react-native-reanimated-carousel": "^3.5.1",
"react-native-safe-area-context": "^4.9.0",
"react-native-safe-area-context": "^4.10.1",
"react-native-screens": "3.29.0",
"react-native-shadow-2": "^7.0.8",
"react-native-share-menu": "git+https://github.com/lovegaoshi/react-native-share-menu.git",
"react-native-svg": "^15.1.0",
"react-native-svga-player": "git+https://[email protected]/lovegaoshi/react-native-svga-player.git",
"react-native-svg": "^15.2.0",
"react-native-svga-player": "https://[email protected]/lovegaoshi/react-native-svga-player.git#commit=588c9a2819cb2fe14dd7204addaeadd4bf049333",
"react-native-tab-view": "^3.5.2",
"react-native-text-ticker": "git+https://[email protected]/lovegaoshi/react-native-text-ticker.git",
"react-native-track-player": "git+https://[email protected]/lovegaoshi/react-native-track-player.git#APM",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.0.3",
"react-native-video": "git+https://github.com/lovegaoshi/react-native-video.git#dev-android-cache",
"react-native-webview": "^13.8.6",
"react-native-windows": "^0.73.11",
"react-use": "^17.5.0",
"sp-react-native-in-app-updates": "^1.4.0",
"use-debounce": "^10.0.0",
"uuid": "^9.0.1",
"youtubei.js": "^9.3.0",
"ytdl-core": "git+https://[email protected]/lovegaoshi/node-ytdl-core.git",
"zustand": "^4.5.2"
},
Expand All @@ -114,6 +113,7 @@
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/plugin-syntax-import-attributes": "^7.24.1",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.24.1",
"@babel/runtime": "^7.24.4",
Expand All @@ -138,6 +138,7 @@
"argparse": "^2.0.1",
"babel-jest": "^29.7.0",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-transform-remove-console": "^6.9.4",
"cpx": "^1.5.0",
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -163,4 +164,4 @@
},
"isSwift": true,
"packageManager": "[email protected]"
}
}
3 changes: 1 addition & 2 deletions src/components/buttons/LottieButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useRef } from 'react';
import { Pressable } from 'react-native';
import { Pressable, ViewStyle } from 'react-native';
import LottieView, { AnimationObject } from 'lottie-react-native';

import { useNoxSetting } from '@stores/useApp';
import ShadowedElement from './ShadowedElement';
import { ViewStyle } from 'react-native-windows';

interface Props {
src: AnimationObject;
Expand Down
2 changes: 1 addition & 1 deletion src/components/explore/bilibili/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default () => {
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
<BiliSongsTabCard songs={biliRanking} title={t('BiliCategory.ranking')} />
<Text style={{ fontSize: 20, paddingLeft: 5, paddingBottom: 10 }}>
{t('BiliCategory.dynamic')}
</Text>
Expand All @@ -70,7 +71,6 @@ export default () => {
songs={biliMusicTop}
title={t('BiliCategory.top')}
/>
<BiliSongsTabCard songs={biliRanking} title={t('BiliCategory.ranking')} />
</ScrollView>
);
};
3 changes: 1 addition & 2 deletions src/components/playlist/Menu/PlaylistSortButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from 'react';
import { Menu, Checkbox, Text } from 'react-native-paper';
import { useTranslation } from 'react-i18next';
import { View, StyleSheet } from 'react-native';

import Dialog from '@components/dialogs/GenericSelectDialog';
import { SortOptions } from '@enums/Playlist';
import { StyleSheet } from 'react-native-windows';
import { View } from 'react-native';

const ICON = 'sort';

Expand Down
33 changes: 33 additions & 0 deletions src/hooks/usePlayStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import SpInAppUpdates, {
NeedsUpdateResponse,
IAUUpdateKind,
StartUpdateOptions,
} from 'sp-react-native-in-app-updates';
import { Platform } from 'react-native';

// eslint-disable-next-line import/no-unresolved
import { APPSTORE } from '@env';

export default () => {
const inAppUpdates = new SpInAppUpdates(
false // isDebug
);

const checkPlayStoreUpdates = async () => {
if (Platform.OS !== 'android' || !APPSTORE) return;
// curVersion is optional if you don't provide it will automatically take from the app using react-native-device-info
const result = await inAppUpdates.checkNeedsUpdate();
if (result.shouldUpdate) {
let updateOptions: StartUpdateOptions = {};
if (Platform.OS === 'android') {
// android only, on iOS the user will be promped to go to your app store page
updateOptions = {
updateType: IAUUpdateKind.FLEXIBLE,
};
}
inAppUpdates.startUpdate(updateOptions); // https://github.com/SudoPlz/sp-react-native-in-app-updates/blob/master/src/types.ts#L78
}
};

return { checkPlayStoreUpdates };
};
3 changes: 3 additions & 0 deletions src/hooks/useSetupPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { songlistToTracklist } from '@utils/RNTPUtils';
import useInitializeStore from '@stores/initializeStores';
import { IntentData } from '@enums/Intent';
import { useNoxSetting } from '@stores/useApp';
import usePlayStore from './usePlayStore';

const { NoxAndroidAutoModule } = NativeModules;

Expand All @@ -21,6 +22,7 @@ export default ({ intentData }: NoxComponent.AppProps) => {
const { updateVersion, checkVersion } = useVersionCheck();
const setIntentData = useNoxSetting(state => state.setIntentData);
const { i18n } = useTranslation();
const { checkPlayStoreUpdates } = usePlayStore();

useEffect(() => {
let unmounted = false;
Expand Down Expand Up @@ -53,6 +55,7 @@ export default ({ intentData }: NoxComponent.AppProps) => {
if (unmounted) return;
setPlayerReady(true);
if (unmounted) return;
checkPlayStoreUpdates();
const currentQueue = getCurrentTPQueue();
const findCurrentSong = currentQueue.find(
val => val.id === currentPlayingID
Expand Down
6 changes: 5 additions & 1 deletion src/stores/useSnack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export enum SnackType {
Processing = 'processing',
}

export default create<NoxSnack>(set => ({
export default create<NoxSnack>((set, get) => ({
snackMsg: 'The quick brown fox jumps over the lazy dog.',
snackVisible: false,
snackType: SnackType.Success,
Expand All @@ -44,6 +44,10 @@ export default create<NoxSnack>(set => ({
callback,
processFunction,
}) => {
if (get().snackVisible) {
set({ snackVisible: false });
await new Promise(resolve => setTimeout(resolve, 100));
}
if (processFunction) {
set({
snackMsg: snackMsg.processing || 'processing...',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Bilibili/bilifavOperate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const syncFavlist = async (
const uniqBVIDs = getPlaylistUniqBVIDs(favlist);
await addToBiliFavlist(
favid,
uniqBVIDs.filter(val => val.startsWith('BV')),
uniqBVIDs.filter(val => val.startsWith('BV')).reverse(),
progressEmitter
);
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/mediafetch/biliMusicTop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const API =

const topToSong = (data: any) =>
SongTS({
cid: `null-${data.mv_bvid}`,
bvid: data.mv_bvid,
cid: `null-${data.creation_bvid}`,
bvid: data.creation_bvid,
name: data.creation_title,
nameRaw: data.creation_title,
singer: data.creation_nickname,
singerId: data.creation_up,
cover: data.creation_cover,
lyric: '',
page: 1,
duration: data.creation_title,
duration: data.creation_duration,
album: data.creation_title,
source: Source.bilivideo,
});
Expand Down
8 changes: 4 additions & 4 deletions src/utils/mediafetch/headRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { Source } from '@enums/MediaFetch';
const headFetch = async (url: string): Promise<NoxMedia.Song | undefined> => {
if (!url.startsWith('https://')) return;
try {
const res = await bfetch(url, {
method: 'HEAD',
});
const res = await bfetch(url, { method: 'HEAD' });
if (res.headers.get('content-type')?.startsWith('audio')) {
const fn = url.substring(url.lastIndexOf('/') + 1);
const urlObj = new URL(url);
const fn = urlObj.pathname.substring(
urlObj.pathname.lastIndexOf('/') + 1
);
return SongTS({
cid: `${Source.rawhttp}-${url}`,
bvid: url,
Expand Down
1 change: 1 addition & 0 deletions src/utils/mediafetch/resolveURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const fetchPlayUrlPromise = async (
[steriatkFetch.regexResolveURLMatch, steriatkFetch.resolveURL],
[biliaudioFetch.regexResolveURLMatch, biliaudioFetch.resolveURL],
[ytbvideoFetch.regexResolveURLMatch, ytbvideoFetch.resolveURL],
[ytbvideoFetch.regexResolveURLMatch2, ytbvideoFetch.resolveURL],
[bililiveFetch.regexResolveURLMatch, bililiveFetch.resolveURL],
[biliBangumiFetch.regexResolveURLMatch, biliBangumiFetch.resolveURL],
[localFetch.regexResolveURLMatch, localFetch.resolveURL],
Expand Down
Loading
Loading