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

Move Audio Hook to new audio package #683

Conversation

dmkirshon
Copy link
Contributor

Moves usePlayAudioUrl hook to own package. Refactors state management to utilize useContext and useReducer. Overall done to simplify and make hook more modular and self-contained.

@dmkirshon dmkirshon self-assigned this Jun 13, 2024
@dmkirshon dmkirshon requested review from scandycuz and escobarjonatan and removed request for scandycuz June 13, 2024 10:25
Copy link

github-actions bot commented Jun 13, 2024

Visit the preview URL for this PR (updated for commit 71ddb8e):

https://newm-artist-portal--pr683-create-audio-package-e0v8kl3e.web.app

(expires Sun, 14 Jul 2024 09:04:08 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: ec3483d4c62309afc398865bfd6a9fc9e03e1d46

Copy link

Visit the studio preview URL for this PR 🚀 : https://683.artist.preview.newm.io/

Copy link

Visit the tools preview URL for this PR (updated for commit 0c184c2):
🚀 https://anjfhpbed45unnjio52felp6fe0bfuws.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit 0c184c2):
🚀 https://qit2txm6i7yfnkf37byeccilpa0eazxu.lambda-url.us-west-2.on.aws/

Copy link

Visit the marketplace preview URL for this PR (updated for commit 0c184c2):
🚀 https://63szvkefjyjqbmqr4aoeepjxoy0avzqj.lambda-url.us-west-2.on.aws/

Copy link

Visit the tools preview URL for this PR (updated for commit 1153c33):
🚀 https://anjfhpbed45unnjio52felp6fe0bfuws.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit 1153c33):
🚀 https://qit2txm6i7yfnkf37byeccilpa0eazxu.lambda-url.us-west-2.on.aws/

Copy link

Visit the marketplace preview URL for this PR (updated for commit 1153c33):
🚀 https://63szvkefjyjqbmqr4aoeepjxoy0avzqj.lambda-url.us-west-2.on.aws/

Copy link
Contributor

@scandycuz scandycuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a minor comment but LGTM!

SetAudioProgressAction,
SetAudioUrlAction,
SetIsAudioPlayingAction,
} from "./types";
Copy link
Contributor

@scandycuz scandycuz Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, however, another way to create and define the actions in less code is to use createAction from redux/toolkit. E.g.

import { createAction } from "@reduxjs/toolkit";

...

const SET_AUDIO = "setAudio"

const setAudio = createAction<Howl | undefined>(SET_AUDIO)

instead of

export interface SetAudioAction {
  readonly payload: Howl | undefined;
  readonly type: typeof SET_AUDIO;
}

export const setAudio = (payload: AudioState["audio"]): SetAudioAction => {
  return {
    payload,
    type: "setAudio",
  };
};

case "resetAudioState":
return initialState;
case "setAudio":
return { ...state, audio: action.payload };
Copy link
Contributor

@scandycuz scandycuz Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that can be good to do, just to ensure all of the string values are accurate, is to use the action type variables here. E.g.

import { SET_AUDIO } from "./types";

...

case SET_AUDIO:
    return { ...state, audio: action.payload };

Copy link

Visit the tools preview URL for this PR (updated for commit 559d778):
🚀 https://anjfhpbed45unnjio52felp6fe0bfuws.lambda-url.us-west-2.on.aws/

Copy link

Visit the wallet preview URL for this PR (updated for commit 559d778):
🚀 https://qit2txm6i7yfnkf37byeccilpa0eazxu.lambda-url.us-west-2.on.aws/

Copy link

Visit the marketplace preview URL for this PR (updated for commit 559d778):
🚀 https://63szvkefjyjqbmqr4aoeepjxoy0avzqj.lambda-url.us-west-2.on.aws/

@dmkirshon dmkirshon merged commit 519d5c8 into MRKT-27-Single-Item-for-Play_Update-for-universal-playback Jun 14, 2024
7 checks passed
@dmkirshon dmkirshon deleted the create-audio-package-to-handle-audio-state branch June 14, 2024 09:10
dmkirshon added a commit that referenced this pull request Jun 19, 2024
* feat: Add audio module to packages for marketplace

* feat: Incorporate audio module into audio hook

* fix: Change Marketplace dev port back to original

* fix: Add Howl type import to not break build

* Move Audio Hook to new audio package (#683)

* refactor: Move audio hook to own package

* fix: Set port back to initial value

* refactor: Improve use of types to reduce mistypes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants