1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-15 23:28:31 +09:00
YuruToot/app/javascript/flavours/glitch/actions/picture_in_picture.ts
Renaud Chaput 371c5e59eb [Glitch] Rewrite PIP state in Typescript
Port 9fbe8d3a0c to glitch-soc

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2024-05-01 15:56:37 +02:00

32 lines
951 B
TypeScript

import { createAction } from '@reduxjs/toolkit';
import type { PIPMediaProps } from 'flavours/glitch/reducers/picture_in_picture';
import { createAppAsyncThunk } from 'flavours/glitch/store/typed_functions';
interface DeployParams {
statusId: string;
accountId: string;
playerType: 'audio' | 'video';
props: PIPMediaProps;
}
export const removePictureInPicture = createAction('pip/remove');
export const deployPictureInPictureAction =
createAction<DeployParams>('pip/deploy');
export const deployPictureInPicture = createAppAsyncThunk(
'pip/deploy',
(args: DeployParams, { dispatch, getState }) => {
const { statusId } = args;
// Do not open a player for a toot that does not exist
// @ts-expect-error state.statuses is not yet typed
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (getState().hasIn(['statuses', statusId])) {
dispatch(deployPictureInPictureAction(args));
}
},
);