Skip to content

Commit

Permalink
Merge pull request #709 from lovegaoshi/dev
Browse files Browse the repository at this point in the history
fix: songList scrollTo
  • Loading branch information
lovegaoshi authored Jan 5, 2025
2 parents 6a9b1ef + 8da098e commit 4298cb4
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 133 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"@react-navigation/native": "^7.0.14",
"@react-navigation/native-stack": "^7.2.0",
"@revenuecat/purchases-js": "^0.15.1",
"@sentry/react-native": "^6.4.0",
"@sentry/react-native": "^6.5.0",
"@sharcoux/slider": "8.0.6",
"@shopify/flash-list": "^1.7.2",
"@shopify/react-native-skia": "1.7.7",
"@shopify/react-native-skia": "1.8.0",
"axios": "^1.7.9",
"base-64": "^1.0.0",
"base64-js": "^1.5.1",
Expand Down Expand Up @@ -111,10 +111,10 @@
"react-native-svg": "15.10.1",
"react-native-svga-player": "https://[email protected]/lovegaoshi/react-native-svga-player.git#commit=f8c6303fddb528a1a94d2ab4696c9318c0002cfd",
"react-native-text-ticker": "https://[email protected]/lovegaoshi/react-native-text-ticker.git#commit=b9eb454b18bb621a769ce4b57b4603a81501b477",
"react-native-track-player": "https://github.com/lovegaoshi/react-native-track-player.git#commit=c032d75d82e8f567e2da2a4c7920264bf56fa5e1",
"react-native-track-player": "https://github.com/lovegaoshi/react-native-track-player.git#commit=21184ac50c006646398217ac60bfc399856efe93",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.2.0",
"react-native-video": "^6.8.2",
"react-native-video": "^6.9.0",
"react-native-webview": "13.12.5",
"sp-react-native-in-app-updates": "^1.4.0",
"text-encoding-polyfill": "^0.6.7",
Expand Down Expand Up @@ -142,9 +142,9 @@
"@types/d3": "^7.4.3",
"@types/he": "^1.2.3",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.13",
"@types/lodash": "^4.17.14",
"@types/md5": "^2.3.5",
"@types/node": "^22.10.2",
"@types/node": "^22.10.5",
"@types/qs": "^6.9.17",
"@types/react": "~18.3.18",
"@types/react-native": "^0.73.0",
Expand Down
17 changes: 14 additions & 3 deletions src/components/playlist/usePlaylistRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ export default (playlist: NoxMedia.Playlist) => {
const scrollTo = ({
toIndex = -1,
reset = false,
viewPosition = -4,
viewPosition = 0.5,
}: ScrollTo) => {
let currentIndex =
toIndex < 0
? playlist.songList.findIndex(song => song.id === currentPlayingId)
: toIndex;
if (currentIndex === -1 && reset) currentIndex = 0;
let layoutHeightCheck = 0;
if (currentIndex > -1) {
execWhenTrue({
executeFn: () =>
Expand All @@ -142,8 +143,18 @@ export default (playlist: NoxMedia.Playlist) => {
viewPosition: viewPosition,
animated: false,
}),
// @ts-expect-error detect if flashlist is rendered
loopCheck: () => playlistRef?.current?.rlvRef._layout.height > 0,
loopCheck: async () => {
// @ts-expect-error detect if flashlist is rendered
const layoutHeight = playlistRef?.current?.rlvRef._layout.height;
if (layoutHeight < 1.1) {
return false;
}
if (layoutHeightCheck !== layoutHeight) {
layoutHeightCheck = layoutHeight;
return false;
}
return true;
},
});
}
};
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useSetupPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useNoxSetting } from '@stores/useApp';
import usePlayStore from './usePlayStore';
import { buildBrowseTree } from './usePlaybackAA';
import { NativeModules } from 'react-native';
import useActiveTrack from './useActiveTrack';
import useActiveTrack, { useTrackStore } from './useActiveTrack';

const { NoxModule } = NativeModules;

Expand Down Expand Up @@ -58,6 +58,7 @@ export default ({ intentData, vip }: NoxComponent.SetupPlayerProps) => {
const { checkPlayStoreUpdates } = usePlayStore();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _activeTrack = useActiveTrack();
const setTrack = useTrackStore(state => state.setTrack);

useEffect(() => {
if (!vip) {
Expand All @@ -77,6 +78,7 @@ export default ({ intentData, vip }: NoxComponent.SetupPlayerProps) => {
if (unmounted) return;
checkPlayStoreUpdates();
setIntentData(intentData);
setTrack(await TrackPlayer.getActiveTrack());
if (!(await TrackPlayer.validateOnStartCommandIntent())) {
TrackPlayer.play();
} else {
Expand Down
Loading

0 comments on commit 4298cb4

Please sign in to comment.