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

Version Packages [TEST PROPOSAL] #1164

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": "@changesets/changelog-git",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "develop",
"updateInternalDependencies": "patch",
"ignore": []
}
7 changes: 5 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ jobs:
if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: yarn resolve-workspace-deps
if: github.ref == 'refs/heads/master'
- run: yarn lerna publish from-package --yes --no-verify-access
- uses: changesets/action@v1
with:
publish: yarn release
if: github.ref == 'refs/heads/master'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn bump-next
if: github.ref == 'refs/heads/develop'
- run: yarn release-next
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tools/*"
],
"devDependencies": {
"@changesets/cli": "~2.26.2",
"bump": "workspace:~",
"husky": "~7.0.4",
"hygen": "~6.1.5",
Expand All @@ -30,6 +31,7 @@
"resolve-workspace-deps": "yarn workspace scripts run resolve-workspace-deps",
"create-package": "hygen create-package",
"bump-next": "yarn workspaces foreach --no-private -v run bump-next",
"release": "yarn changesets publish",
"release-next": "yarn workspaces foreach --no-private -v npm publish --tag next --tolerate-republish"
},
"devEngines": {
Expand Down
6 changes: 6 additions & 0 deletions packages/fuselage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 0.31.26

### Patch Changes

- 37a56b3cf: fix(fuselage): AudioPlayer: Infinity duration audio files crashing

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket.chat/fuselage",
"version": "0.31.25",
"version": "0.31.26",
"description": "Rocket.Chat's React Components Library",
"author": {
"name": "Rocket.Chat",
Expand Down
36 changes: 34 additions & 2 deletions packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ function forceDownload(url: string, fileName?: string) {
xhr.send();
}

const getDurationForInfinityDurationAudioFile = (
src: string,
callback: (duration: number) => void
) => {
const audioElement = new Audio();
audioElement.src = src;

audioElement.addEventListener('loadedmetadata', () => {
const { duration } = audioElement;
if (duration === Infinity) {
audioElement.currentTime = 1e101;
return;
}

return callback(duration);
});

audioElement.addEventListener('durationchange', () => {
if (audioElement.duration === Infinity) {
return;
}
callback(audioElement.duration);
audioElement.remove();
});
};

export const AudioPlayer = forwardRef<
HTMLAudioElement,
{
Expand Down Expand Up @@ -169,8 +195,14 @@ export const AudioPlayer = forwardRef<
onTimeUpdate={(e) => {
setCurrentTime((e.target as HTMLAudioElement).currentTime);
}}
onLoadedData={(e) => {
setDurationTime((e.target as HTMLAudioElement).duration);
onLoadedMetadata={(e) => {
const { duration } = e.target as HTMLAudioElement;

if (duration !== Infinity) {
return setDurationTime(duration);
}

getDurationForInfinityDurationAudioFile(src, setDurationTime);
}}
onEnded={() => setIsPlaying(false)}
ref={refs}
Expand Down
Loading
Loading