feat(app,learn): shared spaces' members on the device
Step 4 (e) of ADR 0044, its first part, for every app's screens. - halkyon_app: `SharedSpaceGateway` on the module's `sharedSpace` endpoint (the spaces, their members and roles, inviting, handing on, leaving), refusals as `SpaceRefused`; `SharedKeys.trustIn` gives each member's safety code and whether it was compared or their keys changed, `markCompared`, and `trustNewKeys`, which pins the keys whose code was compared and never those the instance hands next. `FakeSharedSpaceServer` keeps the module's rules for tests, in step with `FakeSharedKeysServer`, which now knows members' handles. - Learn's sharing makes its space through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
4b900aa930
commit
02bb24428c
2 changed files with 688 additions and 10 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:halkyon_app/halkyon_app.dart' show SharedSpaceGateway;
|
||||
|
||||
import 'package:halkyon_learn_flutter/src/core/privacy/data/privacy.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/work/work_progress.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/archive/data/archive_exporter.dart';
|
||||
|
|
@ -8,7 +10,6 @@ import 'package:halkyon_learn_flutter/src/feature/archive/model/import_archive.d
|
|||
import 'package:halkyon_learn_flutter/src/feature/export/data/studyset_markdown.dart'
|
||||
show ExportFile;
|
||||
import 'package:halkyon_learn_flutter/src/feature/publish/data/publish_gateway.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/sharing/data/shared_space_gateway.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_deletions.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset_tree.dart';
|
||||
|
|
@ -90,6 +91,9 @@ class StudysetSharing(
|
|||
final ArchiveImporter _importer,
|
||||
final StudysetDeletions _deletions,
|
||||
) {
|
||||
/// What a Learn space holds, in the module's words for it.
|
||||
static const spaceKind = 'studyset';
|
||||
|
||||
static final _stages = WorkStages(
|
||||
SharingStage.values,
|
||||
weights: const {SharingStage.reading: 2, SharingStage.content: 2},
|
||||
|
|
@ -116,7 +120,7 @@ class StudysetSharing(
|
|||
}
|
||||
abort?.check();
|
||||
|
||||
final space = await _spaces.create();
|
||||
final space = await _spaces.create(spaceKind);
|
||||
try {
|
||||
await _setup.ready(space);
|
||||
onProgress?.call(_stages.at(SharingStage.space, done: 1, total: 1));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart'
|
||||
show SharedSpaceGateway, SpaceInfo, SpaceMember, SpaceRole;
|
||||
import 'package:halkyon_app/testing.dart'
|
||||
show FakeFileServerGateway, MemoryFileCache;
|
||||
import 'package:halkyon_editor/halkyon_editor.dart';
|
||||
|
|
@ -18,7 +20,6 @@ import 'package:halkyon_learn_flutter/src/feature/learning_path/data/path_progre
|
|||
import 'package:halkyon_learn_flutter/src/feature/note/data/note_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/pdf_source/data/pdf_source_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/publish/model/publication.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/sharing/data/shared_space_gateway.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/sharing/data/studyset_sharing.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/study/data/review_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/study/model/rating.dart';
|
||||
|
|
@ -303,7 +304,8 @@ class _Spaces() implements SharedSpaceGateway {
|
|||
final deleted = <String>[];
|
||||
|
||||
@override
|
||||
Future<String> create() async {
|
||||
Future<String> create(String kind) async {
|
||||
expect(kind, 'studyset');
|
||||
final space = 'space-${made.length + 1}';
|
||||
made.add(space);
|
||||
return space;
|
||||
|
|
@ -311,6 +313,32 @@ class _Spaces() implements SharedSpaceGateway {
|
|||
|
||||
@override
|
||||
Future<void> delete(String space) async => deleted.add(space);
|
||||
|
||||
@override
|
||||
Future<List<SpaceInfo>> mine() => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<List<SpaceMember>> members(String space) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<SpaceMember> invite(String space, String handle, SpaceRole role) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> setRole(String space, String member, SpaceRole role) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> remove(String space, String member) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> handOn(String space, String member) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> leave(String space, {String? nextOwner}) =>
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
/// The device's side of a new space: the spaces readied and the studysets
|
||||
|
|
|
|||
Loading…
Reference in a new issue