Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 45fa647

Browse files
committed
Convert SendHistoryManager to TS
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 5f615bd commit 45fa647

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/SendHistoryManager.js renamed to src/SendHistoryManager.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ limitations under the License.
1616
*/
1717

1818
import {clamp} from "lodash";
19+
import {SerializedPart} from "./editor/parts";
20+
import EditorModel from "./editor/model";
1921

2022
export 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

Comments
 (0)