Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Command History to Storage #137

Merged
merged 3 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Lich might also be `lich.rbw` on your setup. You can run multiple connections (f
- [ ] Macros
- [ ] Saved Logging
- [ ] Download Public Themes
- [ ] Clickable links
- [x] Clickable links in game feed and ESP/LNet

## Meta Shortcuts

Expand Down
13 changes: 12 additions & 1 deletion src/session/command-history.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const LimitedList = require("../util/limited-list")
const Storage = require("../storage")

module.exports = class CommandHistory {
static of() {
Expand All @@ -9,14 +10,24 @@ module.exports = class CommandHistory {
*/
constructor() {
this.index = 0
this.buffer = LimitedList.of([], { limit: 100 })

// Load commands from storage
this.buffer = LimitedList.of(
Storage.get(`commandHistory`),
{
limit: 100,
}
)
}

add(command) {
if (this.head().length == 0) {
return (this.buffer.members[0] = command)
}
this.buffer.lpush(command)

// Save commands into storage
Storage.set(`commandHistory`, this.buffer.members)
}

get last_index() {
Expand Down