Skip to content

Commit

Permalink
add webdav settings
Browse files Browse the repository at this point in the history
  • Loading branch information
springeye committed Jun 13, 2023
1 parent 20181aa commit d1c56b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/bloc/ssh_config_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:bloc/bloc.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:fterm/db/ssh_config_dao.dart';
import 'package:fterm/model/ssh_config.dart';
Expand All @@ -20,12 +21,12 @@ class SshConfigBloc extends Bloc<SshConfigEvent, SshConfigState> {
on<SshConfigEvent>((event, emit) async {
await event.map(load: (e) async {
var dao = getIt<SSHConfigDao>();
var items = await dao.findAllSSHConfig();
emit(state.copyWith(configs: items));
await emit.forEach(dao.watchAllSSHConfig(), onData: (items) {
return state.copyWith(configs: items);
});
}, add: (e) async {
var dao = getIt<SSHConfigDao>();
dao.saveSSHConfig(e.config);
add(const SshConfigEvent.load());
});
});
}
Expand All @@ -46,6 +47,5 @@ class SshConfigBloc extends Bloc<SshConfigEvent, SshConfigState> {
var items = list.map((e) => SSHConfig.fromJson(e)).toList();
var dao = getIt<SSHConfigDao>();
await dao.saveSSHConfigs(items);
add(const SshConfigEvent.load());
}
}
23 changes: 21 additions & 2 deletions lib/db/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/db/ssh_config_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ abstract class SSHConfigDao {
@Query('SELECT * FROM SSHConfig')
Future<List<SSHConfig>> findAllSSHConfig();

@Query('SELECT * FROM SSHConfig')
Stream<List<SSHConfig>> watchAllSSHConfig();

@Query('SELECT * FROM SSHConfig WHERE id = :id')
Future<SSHConfig?> findSSHConfigById(String id);

Expand Down

0 comments on commit d1c56b3

Please sign in to comment.