Skip to content
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
2 changes: 1 addition & 1 deletion KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Share a stream you are running from the **…** menu on your own profile: **Go l

**End stream** in the same menu stops it at once; otherwise it stops showing when the chosen time runs out, and the scheduler clears it within five minutes. Only the platform, the link, and the end time are stored, and they are included in your export.

Sources: [go-live menu](resources/js/components/profile-actions-menu.tsx), [live avatar and card](resources/js/components/live-stream-card.tsx), [validation](app/Http/Requests/UpdateUserLiveRequest.php), [YouTube links](app/Services/LivePlatforms/YouTube.php), [Twitch links](app/Services/LivePlatforms/Twitch.php), [ending streams](app/Jobs/EndLiveStreams.php).
Sources: [go-live button](resources/js/components/profile-live-button.tsx), [live avatar and card](resources/js/components/live-stream-card.tsx), [validation](app/Http/Requests/UpdateUserLiveRequest.php), [YouTube links](app/Services/LivePlatforms/YouTube.php), [Twitch links](app/Services/LivePlatforms/Twitch.php), [ending streams](app/Jobs/EndLiveStreams.php).

### Achievement badges and XP

Expand Down
64 changes: 0 additions & 64 deletions resources/js/components/profile-actions-menu.tsx

This file was deleted.

53 changes: 53 additions & 0 deletions resources/js/components/profile-live-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Radio, RadioOff } from 'lucide-react';
import { useState } from 'react';
import { endStream, GoLiveDialog } from '@/components/go-live-dialog';
import { Button } from '@/components/ui/button';
import type { User } from '@/types';

/**
* Going live, or ending the stream, from your own profile, where other people's profiles have the mute and block menu.
*/
export function ProfileLiveButton({ user }: { user: Pick<User, 'live'> }) {
const [isGoingLive, setIsGoingLive] = useState(false);
const [isEnding, setIsEnding] = useState(false);

return (
<>
{user.live ? (
<Button
type="button"
variant="outline"
size="icon"
className="shrink-0"
disabled={isEnding}
onClick={() =>
endStream({
onStart: () => setIsEnding(true),
onFinish: () => setIsEnding(false),
})
}
aria-label="End stream"
title="End stream"
data-test="end-stream"
>
<RadioOff />
</Button>
) : (
<Button
type="button"
variant="outline"
size="icon"
className="shrink-0"
onClick={() => setIsGoingLive(true)}
aria-label="Go live"
title="Go live"
data-test="go-live"
>
<Radio />
</Button>
)}

<GoLiveDialog open={isGoingLive} onOpenChange={setIsGoingLive} />
</>
);
}
4 changes: 2 additions & 2 deletions resources/js/pages/user/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { LocalTime } from '@/components/local-time';
import { PageTabs } from '@/components/page-tabs';
import { PinCommitButton } from '@/components/pin-commit-button';
import { ProfileActionsMenu } from '@/components/profile-actions-menu';
import { ProfileLiveButton } from '@/components/profile-live-button';
import { ProfileReadme } from '@/components/profile-readme';
import { ProfileShareButton } from '@/components/profile-share-button';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -175,7 +175,7 @@ export default function Show({
/>
{isCurrentUser ? (
<>
<ProfileActionsMenu user={user} />
<ProfileLiveButton user={user} />
<EditProfileMenu />
</>
) : (
Expand Down
25 changes: 25 additions & 0 deletions tests/Unit/ProfileLiveButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference types="node" />
import assert from 'node:assert/strict';
import { renderToStaticMarkup } from 'react-dom/server';
import { test } from 'vite-plus/test';
import { ProfileLiveButton } from '../../resources/js/components/profile-live-button';
Comment thread
coderabbitai[bot] marked this conversation as resolved.

test('offers going live straight from your own profile instead of a menu with one item', () => {
const html = renderToStaticMarkup(
<ProfileLiveButton user={{ live: null }} />,
);

assert.match(html, /<button[^>]*aria-label="Go live"/);
assert.doesNotMatch(html, /aria-haspopup|More options/);
});

test('offers ending the stream while you are live', () => {
const html = renderToStaticMarkup(
<ProfileLiveButton
user={{ live: { url: 'https://twitch.tv/me', thumbnail_url: '' } }}
/>,
);

assert.match(html, /<button[^>]*aria-label="End stream"/);
assert.doesNotMatch(html, /aria-label="Go live"/);
});
Loading