Skip to content

Commit

Permalink
Update Clips APIs (#352)
Browse files Browse the repository at this point in the history
* Update Clips APIs

* Cleanup
  • Loading branch information
lemonmade authored Oct 3, 2024
1 parent 29dba18 commit 1aaf4aa
Show file tree
Hide file tree
Showing 30 changed files with 1,115 additions and 620 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-numbers-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@watching/cli': minor
---

Update Clips upload flow
5 changes: 5 additions & 0 deletions .changeset/new-terms-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@watching/thread-render': patch
---

Put a facade over some signal usage
7 changes: 2 additions & 5 deletions app/browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Env from 'quilt:module/env';

import type {AppContext} from '~/shared/context.ts';
import {SearchParam} from '~/global/auth.ts';
import {createClipsManager} from '~/shared/clips.ts';
import {ClipsManager} from '~/shared/clips.ts';

import App from './App.tsx';
import {EXTENSION_POINTS} from './clips.ts';
Expand Down Expand Up @@ -79,10 +79,7 @@ const context = {
graphql: {cache: new GraphQLCache(), fetch: fetchGraphQL},
performance,
clipsManager: user
? createClipsManager(
{user, graphql: fetchGraphQL, router},
EXTENSION_POINTS,
)
? new ClipsManager({user, graphql: fetchGraphQL, router}, EXTENSION_POINTS)
: undefined,
} satisfies AppContext;

Expand Down
6 changes: 3 additions & 3 deletions app/features/Developer/Console/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Page} from '~/shared/page.ts';
import {
useClipsManager,
useLocalDevelopmentServerQuery,
type ClipsLocalDevelopmentServer,
type ClipsLocalDevelopmentServerType,
} from '~/shared/clips.ts';

import developerConsoleQuery, {
Expand All @@ -37,7 +37,7 @@ export default function Console() {
);
}

function ConnectedConsole({server}: {server: ClipsLocalDevelopmentServer}) {
function ConnectedConsole({server}: {server: ClipsLocalDevelopmentServerType}) {
const {data, loading} = useLocalDevelopmentServerQuery(developerConsoleQuery);

usePerformanceNavigation({state: loading ? 'loading' : 'complete'});
Expand Down Expand Up @@ -119,7 +119,7 @@ function ExtensionBuildResult({
}
}

function ConnectToConsole({server}: {server: ClipsLocalDevelopmentServer}) {
function ConnectToConsole({server}: {server: ClipsLocalDevelopmentServerType}) {
usePerformanceNavigation({state: 'complete'});

const localUrl = useSignal('');
Expand Down
10 changes: 5 additions & 5 deletions app/features/Series/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function SeriesWithData({
<AccessoryClips
id={series.id}
name={series.name}
installations={series.clipsInstallations}
clips={series.clipsToRender}
/>

<SeasonsSection id={series.id} seasons={seasons} onUpdate={onUpdate} />
Expand All @@ -212,13 +212,13 @@ function SeriesWithData({
function AccessoryClips({
id,
name,
installations,
clips,
}: {
id: string;
name: string;
installations: SeriesQueryData.Series['clipsInstallations'];
clips: SeriesQueryData.Series['clipsToRender'];
}) {
const accessoryClips = useClips('series.details.accessory', installations, {
const accessoryClips = useClips('series.details.accessory', clips, {
id,
name,
});
Expand All @@ -228,7 +228,7 @@ function AccessoryClips({
return (
<BlockStack spacing="large">
{accessoryClips.map((clip) => (
<Clip key={clip.id} extension={clip} />
<Clip key={clip.id} extensionPoint={clip} />
))}
</BlockStack>
);
Expand Down
6 changes: 3 additions & 3 deletions app/features/Series/graphql/SeriesQuery.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../../../shared/clips/graphql/ClipsExtensionFragment.graphql"
#import "../../../shared/clips/graphql/ClipsExtensionPointFragment.graphql"

query Series($id: ID, $handle: String) {
series(id: $id, handle: $handle) {
Expand Down Expand Up @@ -55,8 +55,8 @@ query Series($id: ID, $handle: String) {
episode
}
}
clipsInstallations(target: "series.details.accessory") {
...ClipsExtension
clipsToRender(target: "series.details.accessory") {
...ClipsExtensionPoint
}
}
}
22 changes: 12 additions & 10 deletions app/features/WatchThrough/WatchThrough.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function WatchThroughWithData({
settings,
from,
to,
clipsInstallations,
clipsToRender,
} = watchThrough;

const watchingSingleSeason = from.season === to.season;
Expand Down Expand Up @@ -234,7 +234,7 @@ function WatchThroughWithData({
id={id}
url={url}
series={series}
installations={clipsInstallations}
clips={clipsToRender}
currentWatch={nextEpisodeForm}
/>

Expand Down Expand Up @@ -1016,24 +1016,26 @@ function AccessoryClips({
id,
url,
series,
installations,
clips,
currentWatch,
}: Pick<WatchThroughQueryData.WatchThrough, 'id' | 'url' | 'series'> & {
installations: WatchThroughQueryData.WatchThrough['clipsInstallations'];
clips: WatchThroughQueryData.WatchThrough['clipsToRender'];
currentWatch: Signal<WatchForm | undefined>;
}) {
const accessoryClips = useClips(
'watch-through.details.accessory',
installations,
{id, url, seriesId: series.id, seriesName: series.name, currentWatch},
);
const accessoryClips = useClips('watch-through.details.accessory', clips, {
id,
url,
seriesId: series.id,
seriesName: series.name,
currentWatch,
});

if (accessoryClips.length === 0) return null;

return (
<BlockStack spacing="large">
{accessoryClips.map((clip) => (
<Clip key={clip.id} extension={clip} />
<Clip key={clip.id} extensionPoint={clip} />
))}
</BlockStack>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../../../shared/clips/graphql/ClipsExtensionFragment.graphql"
#import "../../../shared/clips/graphql/ClipsExtensionPointFragment.graphql"

fragment WatchThroughDetails on WatchThrough {
id
Expand Down Expand Up @@ -129,7 +129,7 @@ fragment WatchThroughDetails on WatchThrough {
settings {
spoilerAvoidance
}
clipsInstallations(target: "watch-through.details.accessory") {
...ClipsExtension
clipsToRender(target: "watch-through.details.accessory") {
...ClipsExtensionPoint
}
}
4 changes: 2 additions & 2 deletions app/server/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Router} from '@quilted/quilt/navigation';
import {BrowserAssets} from 'quilt:module/assets';

import type {AppContext} from '~/shared/context.ts';
import {createClipsManager} from '~/shared/clips.ts';
import {ClipsManager} from '~/shared/clips.ts';

import App from '../App.tsx';
import {EXTENSION_POINTS} from '../clips.ts';
Expand Down Expand Up @@ -62,7 +62,7 @@ export const handleApp: RequestHandler = async function handleApp(request) {
router,
graphql: {cache: new GraphQLCache(), fetch: fetchGraphQL},
clipsManager: user
? createClipsManager(
? new ClipsManager(
{user, graphql: fetchGraphQL, router},
EXTENSION_POINTS,
)
Expand Down
7 changes: 7 additions & 0 deletions app/server/graphql/resolvers/apps/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ export const AppInstallation = createResolverWithGid('AppInstallation', {
async extensions({id}, _, {prisma}) {
const installations = await prisma.clipsExtensionInstallation.findMany({
where: {appInstallationId: id},
include: {
extension: {
include: {
activeVersion: true,
},
},
},
take: 50,
// orderBy: {createAt, 'desc'},
});
Expand Down
Loading

0 comments on commit 1aaf4aa

Please sign in to comment.