Skip to content

Commit 4e99095

Browse files
authored
Merge pull request #811 from WatchItDev/app/perf
feat: added views count to the videos
2 parents 17b54f3 + ce85662 commit 4e99095

File tree

9 files changed

+22
-10
lines changed

9 files changed

+22
-10
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
#splash img {
9797
z-index: 10;
98-
width: clamp(104px, calc(18vw * 0.8), 160px);
98+
width: clamp(85px, calc(18vw * 0.8), 120px);
9999
height: auto;
100100
transform-origin: center;
101101
will-change: transform, filter;

src/components/login-modal/profile-form-view.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,6 @@ export const ProfileFormView: React.FC<ProfileFormProps> = ({
389389
<TextMaxLine line={1} variant="caption" fontWeight="bold" color="text.secondary">
390390
* Click the profile or cover image to select one
391391
</TextMaxLine>
392-
<TextMaxLine line={1} variant="caption" fontWeight="bold" color="text.secondary">
393-
* Images are optional (current images are placeholders)
394-
</TextMaxLine>
395392
</Box>
396393
</Box>
397394

src/components/subscribe-profile-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export const SubscribeProfileModal = ({
188188
return (
189189
<>
190190
<Dialog open={isOpen} onClose={onClose} fullWidth maxWidth="xs">
191-
<DialogTitle sx={{ pb: 2 }}>Join to {profile?.displayName} content</DialogTitle>
191+
<DialogTitle sx={{ pb: 2 }}>Access {profile?.displayName}'s content</DialogTitle>
192192
<Divider sx={{ mb: 2, borderStyle: 'dashed' }} />
193193
<DialogContent>
194194
{loadingTerms ? (

src/components/video-player/video-player.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import useGetSubtitles from '@src/hooks/protocol/use-get-subtitles.ts';
2121
import { useResponsive } from '@src/hooks/use-responsive';
2222
import Label from '../label';
2323
import {ErrorData} from "hls.js"
24-
import { useLogEventMutation } from '@src/graphql/generated/hooks.tsx';
24+
import { useIncrementPostViewMutation, useLogEventMutation } from '@src/graphql/generated/hooks.tsx';
2525
import { useAuth } from '@src/hooks/use-auth.ts';
2626

2727
export interface VideoPlayerProps {
@@ -41,6 +41,7 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({ src, cid, titleMovie, postId
4141
const controlsVisible = useMediaState('controlsVisible', player);
4242
const { tracks, getSubtitles } = useGetSubtitles();
4343
const [logEvent] = useLogEventMutation();
44+
const [incrementView] = useIncrementPostViewMutation();
4445
const { session } = useAuth();
4546

4647
const watchedSeconds = useRef<Set<number>>(new Set()) // distinct seconds already counted
@@ -69,7 +70,11 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({ src, cid, titleMovie, postId
6970
}
7071
};
7172

72-
const handlePlay = () => emit('VIDEO_START');
73+
const handlePlay = () => {
74+
emit('VIDEO_START');
75+
incrementView({ variables: { postId } });
76+
};
77+
7378
const handleEnded = () => emit('VIDEO_WATCH_FULL');
7479

7580
const handleTimeUpdate = () => {

src/graphql/generated/graphql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ export type IncrementPostViewMutationVariables = Exact<{
871871
}>;
872872

873873

874-
export type IncrementPostViewMutation = { __typename?: 'Mutation', incrementPostView: { __typename?: 'Post', id: string } };
874+
export type IncrementPostViewMutation = { __typename?: 'Mutation', incrementPostView: { __typename?: 'Post', id: string, viewCount: number } };
875875

876876
export type UpdatePostMutationVariables = Exact<{
877877
input: UpdatePostInput;
@@ -1151,7 +1151,7 @@ export const LogAnonymousEventDocument = {"kind":"Document","definitions":[{"kin
11511151
export const LogEventDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"LogEvent"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"LogEventInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logEvent"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}]}]}}]} as unknown as DocumentNode<LogEventMutation, LogEventMutationVariables>;
11521152
export const CreatePostDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreatePost"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreatePostInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createPost"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]} as unknown as DocumentNode<CreatePostMutation, CreatePostMutationVariables>;
11531153
export const HidePostDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"HidePost"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"postId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hidePost"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"postId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postId"}}}]}]}}]} as unknown as DocumentNode<HidePostMutation, HidePostMutationVariables>;
1154-
export const IncrementPostViewDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"IncrementPostView"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"postId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incrementPostView"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"postId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<IncrementPostViewMutation, IncrementPostViewMutationVariables>;
1154+
export const IncrementPostViewDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"IncrementPostView"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"postId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incrementPostView"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"postId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"viewCount"}}]}}]}}]} as unknown as DocumentNode<IncrementPostViewMutation, IncrementPostViewMutationVariables>;
11551155
export const UpdatePostDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdatePost"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdatePostInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updatePost"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}}]}}]}}]} as unknown as DocumentNode<UpdatePostMutation, UpdatePostMutationVariables>;
11561156
export const CreateTipDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateTip"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateTipInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createTip"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"baker"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"creator"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"message"}},{"kind":"Field","name":{"kind":"Name","value":"postId"}},{"kind":"Field","name":{"kind":"Name","value":"txHash"}}]}}]}}]} as unknown as DocumentNode<CreateTipMutation, CreateTipMutationVariables>;
11571157
export const CreateUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UserInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createUser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"xpBalance"}}]}}]}}]} as unknown as DocumentNode<CreateUserMutation, CreateUserMutationVariables>;

src/graphql/generated/hooks.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ export const IncrementPostViewDocument = gql`
375375
mutation IncrementPostView($postId: String!) {
376376
incrementPostView(postId: $postId) {
377377
id
378+
viewCount
378379
}
379380
}
380381
`;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mutation IncrementPostView($postId: String!) {
22
incrementPostView(postId: $postId) {
33
id
4+
viewCount
45
}
56
}

src/layouts/dashboard/header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function Header({ children }: PropsWithChildren) {
6464
>
6565
{sessionData?.authenticated && (
6666
<>
67-
<HeaderXpBalance />
67+
{/*<HeaderXpBalance />*/}
6868
<HeaderMmcBalance />
6969
<NotificationsPopover />
7070
</>

src/sections/publication/components/publication-description.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ export const PublicationTitleDescription: FC<PublicationTitleDescriptionProps> =
4646
{publication?.title}
4747
</Typography>
4848
</m.div>
49+
<m.div variants={variants}>
50+
<Typography
51+
variant="body1"
52+
sx={{ mt: 1, width: '100%', opacity: 0.48 }}
53+
>
54+
{publication?.viewCount} views
55+
</Typography>
56+
</m.div>
4957
<Box sx={{ mt: 2, position: 'relative' }}>
5058
<m.div variants={variants}>
5159
<Box

0 commit comments

Comments
 (0)