import { ProjectUpdatePayload , MobxChange } from '@meetalva/message' ; export function revert ( update ) { return { path : update . path , projectId : update . projectId , change : revertChange ( update . change ) } ; } export function revertChange ( change ) { switch ( change . type ) { case 'add' : return { type : 'remove' , name : change . name , object : change . object , oldValue : change . newValue } ; case 'remove' : return { type : 'add' , name : change . name , object : change . object , oldValue : undefined , newValue : change . oldValue } ; case 'update' : return { type : 'update' , name : ( change as any ) . name , index : ( change as any ) . index , object : change . object , oldValue : change . newValue , newValue : change . oldValue } ; case 'splice' : return { type : 'splice' , object : change . object , index : change . index , added : change . removed , addedCount : change . removedCount , removed : change . added , removedCount : change . addedCount } ; case 'delete' : return { type : 'add' , name : change . name , object : change . object , newValue : change . oldValue } ; } }