change(ui) - session share with unix timestamp (#1187)

* change(ui) - session share with unix timestamp

* change(ui) - session share with unix timestamp
This commit is contained in:
Shekar Siri 2023-11-10 14:39:14 +01:00 committed by GitHub
parent fe62fd79dc
commit fc73d0285d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View file

@ -24,7 +24,7 @@ const TABS = {
let playerInst: IPlayerContext['player'] | undefined;
function WebPlayer(props: any) {
const { session, toggleFullscreen, closeBottomBlock, fullscreen, fetchList } = props;
const { session, toggleFullscreen, closeBottomBlock, fullscreen, fetchList, startedAt } = props;
const { notesStore, sessionStore } = useStore();
const [activeTab, setActiveTab] = useState('');
const [noteItem, setNoteItem] = useState<Note | undefined>(undefined);
@ -79,7 +79,7 @@ function WebPlayer(props: any) {
if (jumpToTime || shouldAdjustOffset) {
if (jumpToTime > visualOffset) {
contextValue.player.jump(parseInt(jumpToTime));
contextValue.player.jump(parseInt(String(jumpToTime - startedAt)));
} else {
contextValue.player.jump(visualOffset);
setAdjusted(true);
@ -168,6 +168,7 @@ export default connect(
fullscreen: state.getIn(['components', 'player', 'fullscreen']),
showEvents: state.get('showEvents'),
members: state.getIn(['members', 'list']),
startedAt: state.getIn(['sessions', 'current']).startedAt || 0,
}),
{
toggleFullscreen,

View file

@ -1,18 +1,20 @@
import React from 'react';
import { connect } from 'react-redux';
import { Button, Icon } from 'UI';
import copy from 'copy-to-clipboard';
import { PlayerContext } from 'App/components/Session/playerContext';
import { observer } from 'mobx-react-lite';
import { DateTime } from 'luxon';
function SessionCopyLink() {
function SessionCopyLink({ startedAt }: any) {
const [copied, setCopied] = React.useState(false);
const { store } = React.useContext(PlayerContext)
const time = store.get().time
const { store } = React.useContext(PlayerContext);
const time = store.get().time;
const copyHandler = () => {
setCopied(true);
copy(window.location.origin + window.location.pathname + '?jumpto=' + Math.round(time));
const timeStr = DateTime.fromMillis(startedAt + time);
copy(window.location.origin + window.location.pathname + '?jumpto=' + parseInt(String(timeStr.toMillis())));
setTimeout(() => {
setCopied(false);
}, 1000);
@ -31,4 +33,9 @@ function SessionCopyLink() {
);
}
export default observer(SessionCopyLink);
export default connect((state: any) => {
return {
time: state.time,
startedAt: state.getIn(['sessions', 'current']).startedAt || 0,
};
})(observer(SessionCopyLink));