Type anys
This commit is contained in:
parent
25d450602f
commit
6f063f6a21
|
@ -51,8 +51,8 @@ export const createHistoryStore = <T extends Document>({
|
||||||
|
|
||||||
// Wrapped versions of essential functions which we call ourselves when using
|
// Wrapped versions of essential functions which we call ourselves when using
|
||||||
// undo and redo
|
// undo and redo
|
||||||
let saveFn: any
|
let saveFn: (doc: T, operationId: string) => Promise<T>
|
||||||
let deleteFn: any
|
let deleteFn: (doc: T, operationId: string) => Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal util to set the loading flag
|
* Internal util to set the loading flag
|
||||||
|
@ -113,15 +113,15 @@ export const createHistoryStore = <T extends Document>({
|
||||||
* @param fn the save function
|
* @param fn the save function
|
||||||
* @returns {function} a wrapped version of the save function
|
* @returns {function} a wrapped version of the save function
|
||||||
*/
|
*/
|
||||||
const wrapSaveDoc = (fn: (doc: any) => Promise<void>) => {
|
const wrapSaveDoc = (fn: (doc: T) => Promise<void>) => {
|
||||||
saveFn = async (doc: any, operationId: string) => {
|
saveFn = async (doc: T, operationId: string) => {
|
||||||
// Only works on a single doc at a time
|
// Only works on a single doc at a time
|
||||||
if (!doc || Array.isArray(doc)) {
|
if (!doc || Array.isArray(doc)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
startLoading()
|
startLoading()
|
||||||
try {
|
try {
|
||||||
const oldDoc = getDoc(doc._id)
|
const oldDoc = getDoc(doc._id!)
|
||||||
const newDoc = jsonpatch.deepClone(await fn(doc))
|
const newDoc = jsonpatch.deepClone(await fn(doc))
|
||||||
|
|
||||||
// Store the change
|
// Store the change
|
||||||
|
@ -161,8 +161,8 @@ export const createHistoryStore = <T extends Document>({
|
||||||
* @param fn the delete function
|
* @param fn the delete function
|
||||||
* @returns {function} a wrapped version of the delete function
|
* @returns {function} a wrapped version of the delete function
|
||||||
*/
|
*/
|
||||||
const wrapDeleteDoc = (fn: (doc: any) => Promise<void>) => {
|
const wrapDeleteDoc = (fn: (doc: T) => Promise<void>) => {
|
||||||
deleteFn = async (doc: any, operationId: string) => {
|
deleteFn = async (doc: T, operationId: string) => {
|
||||||
// Only works on a single doc at a time
|
// Only works on a single doc at a time
|
||||||
if (!doc || Array.isArray(doc)) {
|
if (!doc || Array.isArray(doc)) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue