@@ -16,12 +16,14 @@ limitations under the License.
1616*/
1717
1818import { clamp } from "lodash" ;
19+ import { SerializedPart } from "./editor/parts" ;
20+ import EditorModel from "./editor/model" ;
1921
2022export default class SendHistoryManager {
21- history : Array < HistoryItem > = [];
23+ history : Array < SerializedPart [ ] > = [ ] ;
2224 prefix : string ;
23- lastIndex: number = 0; // used for indexing the storage
24- currentIndex: number = 0; // used for indexing the loaded validated history Array
25+ lastIndex = 0 ; // used for indexing the storage
26+ currentIndex = 0 ; // used for indexing the loaded validated history Array
2527
2628 constructor ( roomId : string , prefix : string ) {
2729 this . prefix = prefix + roomId ;
@@ -45,15 +47,15 @@ export default class SendHistoryManager {
4547 this . currentIndex = this . lastIndex + 1 ;
4648 }
4749
48- save(editorModel: Object ) {
50+ save ( editorModel : EditorModel ) {
4951 const serializedParts = editorModel . serializeParts ( ) ;
5052 this . history . push ( serializedParts ) ;
5153 this . currentIndex = this . history . length ;
5254 this . lastIndex += 1 ;
5355 sessionStorage . setItem ( `${ this . prefix } [${ this . lastIndex } ]` , JSON . stringify ( serializedParts ) ) ;
5456 }
5557
56- getItem(offset: number): ?HistoryItem {
58+ getItem ( offset : number ) : SerializedPart [ ] {
5759 this . currentIndex = clamp ( this . currentIndex + offset , 0 , this . history . length - 1 ) ;
5860 return this . history [ this . currentIndex ] ;
5961 }
0 commit comments