Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-user-override
Browse files Browse the repository at this point in the history
* origin/main:
  Audius Protocol v0.6.112
  Audius Client (Web and Mobile) v1.5.82
  [PAY-2714] track_added_to_purchased_album noti test (#8616)
  [C-3681] Add native mobile buffer (#8606)
  • Loading branch information
schottra committed May 28, 2024
2 parents a81f5f1 + 4089590 commit 5d9081a
Show file tree
Hide file tree
Showing 18 changed files with 263 additions and 32 deletions.
2 changes: 1 addition & 1 deletion mediorum/.version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.6.111",
"version": "0.6.112",
"service": "content-node"
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "1.5.81",
"version": "1.5.82",
"workspaces": [
"packages/*",
"packages/discovery-provider/plugins/pedalboard/apps/*",
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export const MAX_ARTIST_HOVER_TOP_SUPPORTING = 7
export const SUPPORTING_PAGINATION_SIZE = 9

export const MESSAGE_GROUP_THRESHOLD_MINUTES = 2

// Minimum time spent buffering until we show visual indicators (loading spinners, etc)
// Intended to avoid flickering buffer states and avoid showing anything at all if the buffer is short & barely noticeable
export const MIN_BUFFERING_DELAY_MS = 1000
2 changes: 1 addition & 1 deletion packages/discovery-provider/.version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.6.111",
"version": "0.6.112",
"service": "discovery-node"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import logging

from integration_tests.utils import populate_mock_db
from src.api.v1.utils.extend_notification import extend_notification
from src.models.users.usdc_purchase import PurchaseType
from src.queries.get_notifications import NotificationType, get_notifications
from src.utils.db_session import get_db

logger = logging.getLogger(__name__)


def test_get_track_added_to_purchased_album_notifications(app):
with app.app_context():
db_mock = get_db()

test_entities = {
"users": [{"user_id": i + 1} for i in range(2)],
"tracks": [{"track_id": 6, "owner_id": 1}],
"playlists": [
{
"playlist_id": 5,
"playlist_owner_id": 1,
"playlist_name": "name",
"description": "description",
"is_album": True,
"is_stream_gated": True,
"stream_conditions": {
"usdc_purchase": {
"price": 100,
"splits": {
"7gfRGGdp89N9g3mCsZjaGmDDRdcTnZh9u3vYyBab2tRy": 1000000
},
}
},
"playlist_contents": {
"track_ids": [
{"track": 6, "time": 1},
]
},
}
],
"usdc_purchases": [
{
"slot": 4,
"buyer_user_id": 2,
"seller_user_id": 1,
"amount": 1000000,
"content_type": PurchaseType.album,
"content_id": 5,
}
],
}
populate_mock_db(db_mock, test_entities)

test_actions = {
"playlist_tracks": [
{"playlist_id": 5, "track_id": 6},
],
}
populate_mock_db(db_mock, test_actions)

with db_mock.scoped_session() as session:
args = {
"limit": 10,
"user_id": 2,
"valid_types": [NotificationType.TRACK_ADDED_TO_PURCHASED_ALBUM],
}
u2_notifications = get_notifications(session, args)
assert len(u2_notifications) == 1
assert (
u2_notifications[0]["group_id"]
== "track_added_to_purchased_album:playlist_id:5:track_id:6"
)
assert u2_notifications[0]["is_seen"] == False
assert len(u2_notifications[0]["actions"]) == 1
assert u2_notifications[0]["actions"][0]["data"] == {
"track_id": 6,
"playlist_id": 5,
"playlist_owner_id": 1,
}


def test_extended_track_added_to_purchased_album_notification(app):
with app.app_context():
db_mock = get_db()

test_entities = {
"users": [{"user_id": i + 1} for i in range(2)],
"tracks": [{"track_id": 6, "owner_id": 1}],
"playlists": [
{
"playlist_id": 5,
"playlist_owner_id": 1,
"playlist_name": "name",
"description": "description",
"is_album": True,
"is_stream_gated": True,
"stream_conditions": {
"usdc_purchase": {
"price": 100,
"splits": {
"7gfRGGdp89N9g3mCsZjaGmDDRdcTnZh9u3vYyBab2tRy": 1000000
},
}
},
"playlist_contents": {
"track_ids": [
{"track": 6, "time": 1},
]
},
}
],
"usdc_purchases": [
{
"slot": 4,
"buyer_user_id": 2,
"seller_user_id": 1,
"amount": 1000000,
"content_type": PurchaseType.album,
"content_id": 5,
}
],
}
populate_mock_db(db_mock, test_entities)

test_actions = {
"playlist_tracks": [
{"playlist_id": 5, "track_id": 6},
],
}
populate_mock_db(db_mock, test_actions)

with db_mock.scoped_session() as session:
args = {
"limit": 10,
"user_id": 2,
"valid_types": [NotificationType.TRACK_ADDED_TO_PURCHASED_ALBUM],
}
u2_notifications = get_notifications(session, args)
extended_notification = extend_notification(u2_notifications[0])
assert extended_notification["type"] == "track_added_to_purchased_album"
assert (
extended_notification["group_id"]
== "track_added_to_purchased_album:playlist_id:5:track_id:6"
)
assert extended_notification["actions"][0]["specifier"] == "ML51L"
assert (
extended_notification["actions"][0]["type"]
== "track_added_to_purchased_album"
)
assert extended_notification["actions"][0]["data"] == {
"track_id": "AnlGe",
"playlist_id": "pnagD",
"playlist_owner_id": "7eP5n",
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
t4 = t1 - timedelta(hours=3)


def test_get_repost_notifications(app):
def test_get_usdc_purchase_notifications(app):
with app.app_context():
db_mock = get_db()

Expand Down
12 changes: 12 additions & 0 deletions packages/discovery-provider/integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from src.models.playlists.album_price_history import AlbumPriceHistory
from src.models.playlists.playlist import Playlist
from src.models.playlists.playlist_route import PlaylistRoute
from src.models.playlists.playlist_track import PlaylistTrack
from src.models.rewards.challenge import Challenge
from src.models.rewards.challenge_disbursement import ChallengeDisbursement
from src.models.rewards.reward_manager import RewardManagerTransaction
Expand Down Expand Up @@ -119,6 +120,7 @@ def populate_mock_db(db, entities, block_offset=None):

tracks = entities.get("tracks", [])
playlists = entities.get("playlists", [])
playlist_tracks = entities.get("playlist_tracks", [])
users = entities.get("users", [])
developer_apps = entities.get("developer_apps", [])
grants = entities.get("grants", [])
Expand Down Expand Up @@ -296,9 +298,19 @@ def populate_mock_db(db, entities, block_offset=None):
is_image_autogenerated=playlist_meta.get(
"is_image_autogenerated", False
),
is_stream_gated=playlist_meta.get("is_stream_gated", False),
stream_conditions=playlist_meta.get("stream_conditions", None),
)
session.add(playlist)
for i, playlist_track_meta in enumerate(playlist_tracks):
playlist_track = PlaylistTrack(
playlist_id=playlist_track_meta.get("playlist_id", i),
track_id=playlist_track_meta.get("track_id", i),
is_removed=playlist_track_meta.get("is_removed", False),
created_at=datetime.now(),
updated_at=datetime.now(),
)
session.add(playlist_track)

for i, user_meta in enumerate(users):
user = User(
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@audius/mobile",
"version": "1.5.81",
"version": "1.5.82",
"private": true,
"scripts": {
"android:dev": "ENVFILE=.env.dev turbo run android -- --mode=prodDebug",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.7.6","fr":60,"ip":0,"op":301,"w":600,"h":600,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"#White","ln":"White","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":-1,"s":[0]},{"t":300,"s":[1800]}],"ix":10},"p":{"a":0,"k":[300,303,0],"ix":2,"l":2},"a":{"a":0,"k":[300,300,0],"ix":1,"l":2},"s":{"a":0,"k":[90,90,100],"ix":6,"l":2}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[49,49],[49,325.346],[326.457,325.346],[326.457,49]],"c":true},"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"Mask 1"}],"shapes":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.516,0],[0.27,-0.001],[43.768,-37.717],[3.381,-71.148],[0.004,-0.067],[0,-3.994],[0,0],[0,-0.091],[-13.789,0],[0,0],[0.011,13.807],[0,0],[-37.964,37.963],[-53.689,0],[-0.433,-0.003],[-0.054,0],[-0.086,13.753],[13.807,0.087],[0,0]],"o":[[-0.271,0],[-62.264,0.197],[-50.566,43.571],[-0.003,0.067],[-0.184,3.948],[0,0],[0,0.09],[0.011,13.794],[0,0],[13.807,-0.021],[0,0],[0,-53.689],[37.963,-37.964],[0.434,0],[0.054,0],[13.733,0],[0.087,-13.807],[0,0],[-0.516,-0.004]],"v":[[300,49],[299.188,49.001],[136.23,109.783],[49.287,287.886],[49.277,288.092],[49,300],[49,300.111],[49,300.383],[73.98,325.346],[74.019,325.346],[99,300.308],[99,300],[157.872,157.872],[300,99],[301.3,99.004],[301.46,99.005],[326.456,74.162],[301.614,49.005],[301.556,49.005]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false}],"ip":0,"op":1800,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"#Primary","ln":"Primary","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[300,300,0],"ix":2,"l":2},"a":{"a":0,"k":[16,16,0],"ix":1,"l":2},"s":{"a":0,"k":[1862.478,1862.478,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[8.837,0],[0,8.836],[-8.837,0],[0,-8.837]],"o":[[-8.837,0],[0,-8.837],[8.837,0],[0,8.836]],"v":[[0,16],[-16,0],[0,-16],[16,0]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"Merge Paths 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.8,0.059000000299,0.877999997606,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[16.011,16.007],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":5,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1800,"st":0,"bm":0}],"markers":[]}
18 changes: 17 additions & 1 deletion packages/mobile/src/components/audio/AudioPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import TrackPlayer, {
State,
useTrackPlayerEvents,
RepeatMode as TrackPlayerRepeatMode,
TrackType
TrackType,
useIsPlaying
} from 'react-native-track-player'
import { useDispatch, useSelector } from 'react-redux'
import { useAsync, usePrevious } from 'react-use'
Expand Down Expand Up @@ -281,6 +282,21 @@ export const AudioPlayer = () => {
[dispatch]
)

const { bufferingDuringPlay } = useIsPlaying() // react-native-track-player hook

const previousBufferingState = usePrevious(bufferingDuringPlay)

useEffect(() => {
// Keep redux buffering status in sync with react-native-track-player's buffering status
// Only need to dispatch when the value actually changes so we check against the previous value
if (
bufferingDuringPlay !== undefined &&
bufferingDuringPlay !== previousBufferingState
) {
dispatch(playerActions.setBuffering({ buffering: bufferingDuringPlay }))
}
}, [bufferingDuringPlay, dispatch, previousBufferingState])

const makeTrackData = useCallback(
async ({ track, playerBehavior }: QueueableTrack) => {
if (!track) {
Expand Down
3 changes: 3 additions & 0 deletions packages/mobile/src/components/core/AnimatedButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type AnimatedButtonProps = {
hapticsConfig?: Haptics[]
waitForAnimationFinish?: boolean
children?: ReactNode
lottieProps?: Partial<LottieViewProps>
} & PressableProps

export const AnimatedButton = ({
Expand All @@ -51,6 +52,7 @@ export const AnimatedButton = ({
hapticsConfig,
waitForAnimationFinish,
children,
lottieProps,
...pressableProps
}: AnimatedButtonProps) => {
const [iconIndex, setIconIndex] = useState<number>(externalIconIndex ?? 0)
Expand Down Expand Up @@ -201,6 +203,7 @@ export const AnimatedButton = ({
loop={false}
source={source}
resizeMode={resizeMode}
{...lottieProps}
/>
{/**
* Secondary animation that is visible when inactive. This ensures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import { PLAY_BAR_HEIGHT } from './constants'
import { useCurrentTrackDuration } from './useCurrentTrackDuration'
const { seek, reset } = playerActions

const { getPlaying, getCurrentTrack, getCounter, getUid } = playerSelectors
const { getPlaying, getCurrentTrack, getCounter, getUid, getBuffering } =
playerSelectors
const { next, previous } = queueActions
const { getUser } = cacheUsersSelectors

Expand Down Expand Up @@ -117,6 +118,7 @@ export const NowPlayingDrawer = memo(function NowPlayingDrawer(
const playCounter = useSelector(getCounter)
const currentUid = useSelector(getUid)
const isPlaying = useSelector(getPlaying)
const isBuffering = useSelector(getBuffering)
const [isPlayBarShowing, setIsPlayBarShowing] = useState(false)

const { drawerNavigation } = useContext(AppDrawerContext)
Expand Down Expand Up @@ -339,7 +341,7 @@ export const NowPlayingDrawer = memo(function NowPlayingDrawer(
<View style={styles.scrubberContainer}>
<Scrubber
mediaKey={`${mediaKey}`}
isPlaying={isPlaying}
isPlaying={isPlaying && !isBuffering}
onPressIn={onPressScrubberIn}
onPressOut={onPressScrubberOut}
duration={trackDuration}
Expand Down
Loading

0 comments on commit 5d9081a

Please sign in to comment.