forked from krille-chan/fluffychat
-
Notifications
You must be signed in to change notification settings - Fork 5
feat(quests): enforce per-Mission pinned-activity restriction from course-space state #7750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7ff327e
feat(quests): per-course activity pinning from course-space state (cl…
wcjord e33db07
style: dart format quest pin files
wcjord f8b9d4f
style: sort imports in selected_course_page
wcjord b2eeb3a
Merge remote-tracking branch 'origin/main' into feat/mission-activity…
wcjord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import 'package:fluffychat/features/course_plans/courses/course_plan_room_extens | |
| import 'package:fluffychat/features/quests/lo_progression.dart'; | ||
| import 'package:fluffychat/features/quests/quest_progression_resolver.dart'; | ||
| import 'package:fluffychat/features/quests/repo/quest_repo.dart'; | ||
| import 'package:fluffychat/routes/chat/chat_details/teacher_mode_model.dart'; | ||
| import 'package:fluffychat/routes/world/world_map_client_extension.dart'; | ||
| import 'package:fluffychat/widgets/future_loading_dialog.dart'; | ||
|
|
||
|
|
@@ -88,33 +89,41 @@ class JoinedObjectiveCache { | |
| } | ||
|
|
||
| /// [rebuild] from the client's joined courses — each course's quest uuid with | ||
| /// its teacher stars-to-unlock override. The single home for that mapping: | ||
| /// the world map's pins manager and the course panel's star display both | ||
| /// rebuild through here, so every surface resolves identical outlines. | ||
| /// its teacher config (stars-to-unlock override + per-Mission activity pins). | ||
| /// The single home for that mapping: the world map's pins manager and the | ||
| /// course panel's star display both rebuild through here, so every surface | ||
| /// resolves identical outlines. Pins are applied as a pure copy per course | ||
| /// (never to the shared quest-outline cache), so two courses sharing a quest | ||
| /// can restrict differently. | ||
| Future<void> rebuildFromJoinedCourses( | ||
| Client client, { | ||
| void Function(String uuid, Object error, StackTrace stack)? onError, | ||
| }) { | ||
| final thresholds = <String, int>{ | ||
| final modes = <String, TeacherModeModel>{ | ||
| for (final room in client.joinedCourseRooms) | ||
| room.coursePlan!.uuid: | ||
| room.teacherMode.starsToUnlockObjective ?? | ||
| kDefaultStarsToUnlockObjective, | ||
| room.coursePlan!.uuid: room.teacherMode, | ||
| }; | ||
| return rebuild( | ||
| thresholds.keys.toList(), | ||
| modes.keys.toList(), | ||
|
Comment on lines
+102
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Keep course-space identity separate from quest identity. Using
📍 Affects 3 files
🤖 Prompt for AI Agents |
||
| outlineOf: (uuid) => _outlineFromQuest( | ||
| uuid, | ||
| pinnedByObjective: modes[uuid]?.pinnedActivitiesByObjective, | ||
| ), | ||
| starsToUnlockOf: (uuid) => | ||
| thresholds[uuid] ?? kDefaultStarsToUnlockObjective, | ||
| modes[uuid]?.starsToUnlockObjective ?? kDefaultStarsToUnlockObjective, | ||
| onError: onError, | ||
| ); | ||
| } | ||
|
|
||
| static Future<CourseLoOutline> _outlineFromQuest(String uuid) async { | ||
| static Future<CourseLoOutline> _outlineFromQuest( | ||
| String uuid, { | ||
| Map<String, List<String>>? pinnedByObjective, | ||
| }) async { | ||
| final outlineResult = await QuestRepo.outline(uuid); | ||
| final outline = outlineResult.result; | ||
| if (outline == null) { | ||
| throw (outlineResult.error ?? MissingQuestException()); | ||
| } | ||
| return outline.toCourseLoOutline(); | ||
| return outline.restrictedTo(pinnedByObjective).toCourseLoOutline(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Allow
copyWithto clear the pin mapping.copyWith(pinnedActivitiesByObjective: null)currently preserves the old pins, althoughnullis the contract for removing restrictions. Add an explicit clear flag or sentinel.Proposed fix
TeacherModeModel copyWith({ bool? enabled, int? activitiesToUnlockTopic, int? starsToUnlockObjective, Map<String, List<String>>? pinnedActivitiesByObjective, + bool clearPinnedActivitiesByObjective = false, }) { return TeacherModeModel( enabled: enabled ?? this.enabled, activitiesToUnlockTopic: activitiesToUnlockTopic ?? this.activitiesToUnlockTopic, starsToUnlockObjective: starsToUnlockObjective ?? this.starsToUnlockObjective, - pinnedActivitiesByObjective: - pinnedActivitiesByObjective ?? this.pinnedActivitiesByObjective, + pinnedActivitiesByObjective: clearPinnedActivitiesByObjective + ? null + : pinnedActivitiesByObjective ?? this.pinnedActivitiesByObjective, ); }📝 Committable suggestion
🤖 Prompt for AI Agents