mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: sftp jump history
This commit is contained in:
32
lib/data/store/history.dart
Normal file
32
lib/data/store/history.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
|
||||
typedef _HistoryType = List<String>;
|
||||
|
||||
/// index from 0 -> n : latest -> oldest
|
||||
class _History {
|
||||
final _HistoryType _history;
|
||||
final String _name;
|
||||
final Box<_HistoryType> _box;
|
||||
|
||||
_History({
|
||||
required Box<_HistoryType> box,
|
||||
required String name,
|
||||
}) : _box = box,
|
||||
_name = name,
|
||||
_history = box.get(name, defaultValue: <String>[])!;
|
||||
|
||||
void add(String path) {
|
||||
_history.remove(path);
|
||||
_history.insert(0, path);
|
||||
_box.put(_name, _history);
|
||||
}
|
||||
|
||||
_HistoryType get all => _history;
|
||||
}
|
||||
|
||||
class HistoryStore extends PersistentStore<_HistoryType> {
|
||||
late final _History sftpPath = _History(box: box, name: 'sftpPath');
|
||||
|
||||
late final _History sshCmds = _History(box: box, name: 'sshCmds');
|
||||
}
|
||||
Reference in New Issue
Block a user