aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/apis')
-rw-r--r--src/client/apis/recording/RecordingApi.ts (renamed from src/client/apis/recording/recordingApi.tsx)38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/client/apis/recording/recordingApi.tsx b/src/client/apis/recording/RecordingApi.ts
index 97d4e2e7e..64243e443 100644
--- a/src/client/apis/recording/recordingApi.tsx
+++ b/src/client/apis/recording/RecordingApi.ts
@@ -1,7 +1,7 @@
import { CollectionFreeFormView } from "../../views/collections/collectionFreeForm";
import React, { useState } from "react";
-export function RecordingApi() {
+export namespace RecordingApi {
type Movement = {
time: number,
@@ -9,7 +9,7 @@ export function RecordingApi() {
panY: number,
}
- type Presentation = {
+ export type Presentation = {
movements: Array<Movement>
meta: Object,
startDate: Date | null,
@@ -25,7 +25,7 @@ export function RecordingApi() {
const [isRecording, setIsRecording] = useState(false)
const [absoluteStart, setAbsoluteStart] = useState<number>(-1)
- const initAndStart = (view: CollectionFreeFormView, meta?: Object): Error | undefined => {
+ export const initAndStart = (meta?: Object): Error | undefined => {
// check if already init a presentation
if (currentPresentation.startDate !== null) {
console.error('[recordingApi.ts] start() failed: current presentation data exists. please call clear() first.')
@@ -46,7 +46,7 @@ export function RecordingApi() {
setIsRecording(true)
}
- const clear = (): Error | undefined => {
+ export const clear = (): Error | undefined => {
// TODO: maybe archive the data?
if (isRecording) {
console.error('[recordingApi.ts] clear() failed: currently recording presentation. call pause() or finish() first')
@@ -55,17 +55,17 @@ export function RecordingApi() {
// clear presenation data
setCurrentPresenation(NULL_PRESENTATION)
- // clear isRecording
+ // set isRecording false
setIsRecording(false)
- // clear absoluteStart
+ // default absoluteStart
setAbsoluteStart(-1)
}
- const pause = (): Error | undefined => {
+ export const pause = (): Error | undefined => {
if (currentPresentation.startDate === null) {
console.error('[recordingApi.ts] pause() failed: no presentation started. try calling init() first')
- return new Error('[recordingApi.ts] pause(): no presenation')
+ return new Error('[recordingApi.ts] pause()')
}
// don't allow track movments
setIsRecording(false)
@@ -75,7 +75,7 @@ export function RecordingApi() {
setAbsoluteStart(timestamp)
}
- const resume = () => {
+ export const resume = () => {
if (currentPresentation.startDate === null) {
console.error('[recordingApi.ts] resume() failed: no presentation started. try calling init() first')
return new Error('[recordingApi.ts] resume()')
@@ -97,24 +97,26 @@ export function RecordingApi() {
})
}
- const finish = (): Error | Presentation => {
+ export const finish = (): Error | Presentation => {
if (currentPresentation.movements === null) {
console.error('[recordingApi.ts] finish() failed: no presentation data. try calling init() first')
return new Error('[recordingApi.ts] finish()')
}
// make copy and clear this class's data
- const returnCopy = { ...currentPresentation }
- clear()
+ // const returnCopy = { ...currentPresentation }
+ // clear()
+
+ // // return the copy
+ // return returnCopy
- // return the copy
- return returnCopy
+ return currentPresentation
}
- const trackMovements = (panX: number, panY: number): Error | undefined => {
+ export const trackMovements = (panX: number, panY: number): Error | undefined => {
// ensure we are recording
if (!isRecording) {
- console.error('[recordingApi.ts] pause() failed: recording is paused()')
+ console.error('[recordingApi.ts] pause() failed: recording is paused()')
return new Error('[recordingApi.ts] pause()')
}
@@ -134,7 +136,7 @@ export function RecordingApi() {
// TOOD: need to pause all intervals if possible lol
// TODO: extract this into different class with pause and resume recording
- const followMovements = (presentation: Presentation, docView: CollectionFreeFormView): void => {
+ export const followMovements = (presentation: Presentation, docView: CollectionFreeFormView): void => {
const document = docView.Document
const { movements } = presentation
@@ -148,6 +150,4 @@ export function RecordingApi() {
})
}
- return (<></>)
-
} \ No newline at end of file