mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-07 00:24:18 +00:00
Merge pull request 'Fix users cubit, add changelog for 0.5.0' (#87) from NaiJi/selfprivacy.org.app:cubit-users into master
Reviewed-on: https://git.selfprivacy.org/kherel/selfprivacy.org.app/pulls/87
This commit is contained in:
commit
073b7bfcb6
7
fastlane/metadata/android/en-US/changelogs/0.5.0.txt
Normal file
7
fastlane/metadata/android/en-US/changelogs/0.5.0.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
- DKIM key is now deployed to DNS during server setup.
|
||||
- Step 1 of server setup (DNS checks) is now faster.
|
||||
- New DNS management screen: checks current records and lets recreate them if something is wrong.
|
||||
- User creation and deletion is now more responsive.
|
||||
- User list is now synchronized with the server.
|
||||
- New SSH key management screen. SSH keys can now be uploaded for any user, including root.
|
||||
- Root SSH key generation is removed, you can now upload your own keys.
|
1
fastlane/metadata/android/en-US/changelogs/0.5.1.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/0.5.1.txt
Normal file
|
@ -0,0 +1 @@
|
|||
- Fix app trying to load user list before server was created
|
|
@ -17,8 +17,8 @@ class BlocAndProviderConfig extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isDark = false;
|
||||
var usersCubit = UsersCubit();
|
||||
var appConfigCubit = AppConfigCubit()..load();
|
||||
var usersCubit = UsersCubit(appConfigCubit);
|
||||
var servicesCubit = ServicesCubit(appConfigCubit);
|
||||
var backupsCubit = BackupsCubit(appConfigCubit);
|
||||
var dnsRecordsCubit = DnsRecordsCubit(appConfigCubit);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:selfprivacy/config/hive_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/user.dart';
|
||||
|
||||
import '../../api_maps/server.dart';
|
||||
|
@ -10,47 +10,51 @@ export 'package:provider/provider.dart';
|
|||
|
||||
part 'users_state.dart';
|
||||
|
||||
class UsersCubit extends Cubit<UsersState> {
|
||||
UsersCubit()
|
||||
: super(UsersState(
|
||||
<User>[], User(login: 'root'), User(login: 'loading...')));
|
||||
class UsersCubit extends AppConfigDependendCubit<UsersState> {
|
||||
UsersCubit(AppConfigCubit appConfigCubit)
|
||||
: super(
|
||||
appConfigCubit,
|
||||
UsersState(
|
||||
<User>[], User(login: 'root'), User(login: 'loading...')));
|
||||
Box<User> box = Hive.box<User>(BNames.users);
|
||||
Box configBox = Hive.box(BNames.appConfig);
|
||||
|
||||
final api = ServerApi();
|
||||
|
||||
Future<void> load() async {
|
||||
var loadedUsers = box.values.toList();
|
||||
final primaryUser =
|
||||
configBox.get(BNames.rootUser, defaultValue: User(login: 'loading...'));
|
||||
List<String> rootKeys = [
|
||||
...configBox.get(BNames.rootKeys, defaultValue: [])
|
||||
];
|
||||
if (loadedUsers.isNotEmpty) {
|
||||
if (appConfigCubit.state is AppConfigFinished) {
|
||||
var loadedUsers = box.values.toList();
|
||||
final primaryUser = configBox.get(BNames.rootUser,
|
||||
defaultValue: User(login: 'loading...'));
|
||||
List<String> rootKeys = [
|
||||
...configBox.get(BNames.rootKeys, defaultValue: [])
|
||||
];
|
||||
if (loadedUsers.isNotEmpty) {
|
||||
emit(UsersState(
|
||||
loadedUsers, User(login: 'root', sshKeys: rootKeys), primaryUser));
|
||||
}
|
||||
|
||||
final usersFromServer = await api.getUsersList();
|
||||
if (usersFromServer.isSuccess) {
|
||||
final updatedList =
|
||||
mergeLocalAndServerUsers(loadedUsers, usersFromServer.data);
|
||||
emit(UsersState(
|
||||
updatedList, User(login: 'root', sshKeys: rootKeys), primaryUser));
|
||||
}
|
||||
|
||||
final usersWithSshKeys = await loadSshKeys(state.users);
|
||||
// Update the users it the box
|
||||
box.clear();
|
||||
box.addAll(usersWithSshKeys);
|
||||
|
||||
final rootUserWithSshKeys = (await loadSshKeys([state.rootUser])).first;
|
||||
configBox.put(BNames.rootKeys, rootUserWithSshKeys.sshKeys);
|
||||
final primaryUserWithSshKeys =
|
||||
(await loadSshKeys([state.primaryUser])).first;
|
||||
configBox.put(BNames.rootUser, primaryUserWithSshKeys);
|
||||
emit(UsersState(
|
||||
loadedUsers, User(login: 'root', sshKeys: rootKeys), primaryUser));
|
||||
usersWithSshKeys, rootUserWithSshKeys, primaryUserWithSshKeys));
|
||||
}
|
||||
|
||||
final usersFromServer = await api.getUsersList();
|
||||
if (usersFromServer.isSuccess) {
|
||||
final updatedList =
|
||||
mergeLocalAndServerUsers(loadedUsers, usersFromServer.data);
|
||||
emit(UsersState(
|
||||
updatedList, User(login: 'root', sshKeys: rootKeys), primaryUser));
|
||||
}
|
||||
|
||||
final usersWithSshKeys = await loadSshKeys(state.users);
|
||||
// Update the users it the box
|
||||
box.clear();
|
||||
box.addAll(usersWithSshKeys);
|
||||
|
||||
final rootUserWithSshKeys = (await loadSshKeys([state.rootUser])).first;
|
||||
configBox.put(BNames.rootKeys, rootUserWithSshKeys.sshKeys);
|
||||
final primaryUserWithSshKeys =
|
||||
(await loadSshKeys([state.primaryUser])).first;
|
||||
configBox.put(BNames.rootUser, primaryUserWithSshKeys);
|
||||
emit(UsersState(
|
||||
usersWithSshKeys, rootUserWithSshKeys, primaryUserWithSshKeys));
|
||||
}
|
||||
|
||||
List<User> mergeLocalAndServerUsers(
|
||||
|
@ -304,4 +308,9 @@ class UsersCubit extends Cubit<UsersState> {
|
|||
print('UsersState changed');
|
||||
print(change);
|
||||
}
|
||||
|
||||
@override
|
||||
void clear() async {
|
||||
emit(UsersState(<User>[], User(login: 'root'), User(login: 'loading...')));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
part of 'users_cubit.dart';
|
||||
|
||||
class UsersState extends Equatable {
|
||||
class UsersState extends AppConfigDependendState {
|
||||
const UsersState(this.users, this.rootUser, this.primaryUser);
|
||||
|
||||
final List<User> users;
|
||||
|
|
|
@ -8,7 +8,6 @@ import 'package:selfprivacy/logic/cubit/forms/initializing/cloudflare_form_cubit
|
|||
import 'package:selfprivacy/logic/cubit/forms/initializing/domain_cloudflare.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/initializing/hetzner_form_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/initializing/root_user_form_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||
|
|
|
@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:ionicons/ionicons.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: selfprivacy
|
||||
description: selfprivacy.org
|
||||
publish_to: 'none'
|
||||
version: 0.5.0+11
|
||||
version: 0.5.1+12
|
||||
|
||||
environment:
|
||||
sdk: '>=2.13.4 <3.0.0'
|
||||
|
|
Loading…
Reference in a new issue