TelegramPWA/src/global/actions/ui/mediaViewer.ts
2022-04-01 20:43:04 +02:00

80 lines
1.5 KiB
TypeScript

import { addActionHandler } from '../../index';
addActionHandler('openMediaViewer', (global, actions, payload) => {
const {
chatId, threadId, messageId, avatarOwnerId, profilePhotoIndex, origin, volume, playbackRate, isMuted,
} = payload;
return {
...global,
mediaViewer: {
...global.mediaViewer,
chatId,
threadId,
messageId,
avatarOwnerId,
profilePhotoIndex,
origin,
volume: volume ?? global.mediaViewer.volume,
playbackRate: playbackRate || global.mediaViewer.playbackRate,
isMuted: isMuted || global.mediaViewer.isMuted,
},
forwardMessages: {},
};
});
addActionHandler('closeMediaViewer', (global) => {
const { volume, isMuted, playbackRate } = global.mediaViewer;
return {
...global,
mediaViewer: {
volume,
isMuted,
playbackRate,
},
};
});
addActionHandler('setMediaViewerVolume', (global, actions, payload) => {
const {
volume,
} = payload;
return {
...global,
mediaViewer: {
...global.mediaViewer,
volume,
isMuted: false,
},
};
});
addActionHandler('setMediaViewerPlaybackRate', (global, actions, payload) => {
const {
playbackRate,
} = payload;
return {
...global,
mediaViewer: {
...global.mediaViewer,
playbackRate,
},
};
});
addActionHandler('setMediaViewerMuted', (global, actions, payload) => {
const {
isMuted,
} = payload;
return {
...global,
mediaViewer: {
...global.mediaViewer,
isMuted,
},
};
});