Animelon's way of learning from video, from the person's own Jellyfin server: connected per device (Settings, or a studyset's Add material › Watch from Jellyfin) with a name and password or a Quick Connect code, over HTTPS only (plain HTTP only to a server on the same machine); the token stays in the system's keyring. Shows, films and videos tied to a studyset follow the person in their settings as the server's and the item's ids alone (settings schema 9), named by the server when shown. The Watch screen plays the video (video_player on Android, media_kit's libmpv on Linux and Windows) with the line in the studyset's front language cut into the dictionary's words with furigana, and the back language's line beneath; a word tapped pauses the video and becomes a card with the line and its translation as its first hint, tagged with the show. The video's words are listed, most frequent first. The sound is the track in the studyset's language, whichever the file marks default, and the menu switches it; the subtitles read are a whole track, never a forced one (which only covers what the sound doesn't say), and captions for the hard of hearing only without plain ones. The line and its translation take the video's width in a box of a fixed height, so the video keeps its size; in the dark theme the video's colours glow around it, as YouTube's ambient mode, and the words' panel takes the colour of the episode's picture under the pointer. A line is cut into words with one request: DictionaryEndpoint.withKeys looks up every stretch of it that may be a word, as it stands and as every word it may be a conjugation of, in the new dictionary_key table (one row per key, indexed; migration dictionary-keys adds the table and its index, nothing else), which the loader fills beside the entries. The instance gets the text of each line looked up and keeps none of it, as the Watch screen says. Linux builds need libmpv-dev, and the app links libmpv: the snap stages Ubuntu's libmpv2, makes the update-alternatives links for BLAS and LAPACK that ffmpeg's speech recognition needs (staging never runs install scripts), and removes what the GNOME runtime and core24 already hold, as older copies of cairo, pango and librsvg hid the runtime's from its GTK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
145 lines
4.5 KiB
Dart
145 lines
4.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:halkyon_learn_flutter/src/core/content/payload.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/jellyfin/bloc/jellyfin_ties_cubit.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/jellyfin/data/jellyfin_repository.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/jellyfin/model/jellyfin.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/settings/data/settings_payload.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/settings/data/settings_repository.dart';
|
|
import 'package:halkyon_learn_flutter/src/feature/settings/model/person_settings.dart';
|
|
|
|
import '../../support/fake_settings_gateway.dart';
|
|
import '../../support/sample_episode.dart';
|
|
|
|
void main() {
|
|
const elsewhere = JellyfinTie(serverId: 'server-2', itemId: 'show-9');
|
|
late FakeSettingsGateway settingsGateway;
|
|
late SettingsRepository settings;
|
|
late JellyfinRepository jellyfin;
|
|
late JellyfinTiesCubit cubit;
|
|
|
|
setUp(() async {
|
|
settingsGateway = FakeSettingsGateway();
|
|
settings = SettingsRepository(settingsGateway);
|
|
jellyfin = JellyfinRepository(
|
|
(_) => sampleJellyfin(),
|
|
signedInJellyfin(),
|
|
deviceName: 'Test',
|
|
appVersion: '1',
|
|
);
|
|
await jellyfin.open();
|
|
});
|
|
|
|
tearDown(() async {
|
|
await cubit.close();
|
|
await settings.dispose();
|
|
});
|
|
|
|
/// The cubit's state once it settled.
|
|
Future<JellyfinTiesState> settled() async {
|
|
await pumpEventQueue();
|
|
return cubit.state;
|
|
}
|
|
|
|
test("a studyset's ties are the signed-in server's, named as the server "
|
|
'names them now, each tied once', () async {
|
|
await settings.update(
|
|
(settings) => settings.withJellyfinTie('japanese', elsewhere),
|
|
);
|
|
cubit = JellyfinTiesCubit(settings, jellyfin, 'japanese');
|
|
expect((await settled()).items, isEmpty);
|
|
|
|
await cubit.tie(sampleShow);
|
|
await cubit.tie(sampleShow);
|
|
final state = await settled();
|
|
|
|
expect(state.items, [sampleShow]);
|
|
expect(state.isTied('show-1'), isTrue);
|
|
expect((await settings.read()).jellyfinTiesOf('japanese'), [
|
|
elsewhere,
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'show-1'),
|
|
]);
|
|
});
|
|
|
|
test('the instance gets ids only, never a title', () async {
|
|
cubit = JellyfinTiesCubit(settings, jellyfin, 'japanese');
|
|
await cubit.tie(sampleShow);
|
|
await settled();
|
|
|
|
final (_, payload) = settingsGateway.writes.last;
|
|
expect(
|
|
utf8.decode(payload.buffer.asUint8List()),
|
|
isNot(contains('Sample')),
|
|
);
|
|
expect(
|
|
decodePayload(payload, newestSchema: settingsSchemaVersion),
|
|
containsPair('jellyfinTies', {
|
|
'japanese': [
|
|
{'server': 'server-1', 'item': 'show-1'},
|
|
],
|
|
}),
|
|
);
|
|
});
|
|
|
|
test("a tie made on another device shows, named by this device's "
|
|
'server', () async {
|
|
cubit = JellyfinTiesCubit(settings, jellyfin, 'japanese');
|
|
expect((await settled()).items, isEmpty);
|
|
|
|
settingsGateway.receiveRemoteRow(
|
|
'settings-remote',
|
|
encodeSettingsPayload(
|
|
const PersonSettings().withJellyfinTie(
|
|
'japanese',
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'show-1'),
|
|
),
|
|
),
|
|
);
|
|
|
|
expect((await settled()).items, [sampleShow]);
|
|
});
|
|
|
|
test("untying keeps the other servers' ties; an item the server no "
|
|
'longer has is left out', () async {
|
|
await settings.update(
|
|
(settings) => settings
|
|
.withJellyfinTie('japanese', elsewhere)
|
|
.withJellyfinTie(
|
|
'japanese',
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'gone'),
|
|
)
|
|
.withJellyfinTie(
|
|
'japanese',
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'show-1'),
|
|
),
|
|
);
|
|
cubit = JellyfinTiesCubit(settings, jellyfin, 'japanese');
|
|
expect((await settled()).items, [sampleShow]);
|
|
|
|
await cubit.untie('show-1');
|
|
|
|
expect((await settled()).items, isEmpty);
|
|
expect((await settings.read()).jellyfinTiesOf('japanese'), [
|
|
elsewhere,
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'gone'),
|
|
]);
|
|
});
|
|
|
|
test('signed out, nothing is tied', () async {
|
|
await settings.update(
|
|
(settings) => settings.withJellyfinTie(
|
|
'japanese',
|
|
const JellyfinTie(serverId: 'server-1', itemId: 'show-1'),
|
|
),
|
|
);
|
|
cubit = JellyfinTiesCubit(settings, jellyfin, 'japanese');
|
|
expect((await settled()).items, [sampleShow]);
|
|
|
|
await jellyfin.signOut();
|
|
|
|
final state = await settled();
|
|
expect(state.items, isEmpty);
|
|
expect(state.isTied('show-1'), isFalse);
|
|
});
|
|
}
|