merge conflicts
This commit is contained in:
commit
191db0a340
5 changed files with 58 additions and 18 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/extensions/client_extension.dart';
|
||||
import 'package:fluffychat/pangea/pages/class_settings/p_class_widgets/room_rules_editor.dart';
|
||||
import 'package:fluffychat/pangea/widgets/class/add_class_and_invite.dart';
|
||||
import 'package:fluffychat/pangea/widgets/class/add_space_toggles.dart';
|
||||
import 'package:fluffychat/pangea/widgets/space/class_settings.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -80,6 +82,8 @@ class NewSpaceView extends StatelessWidget {
|
|||
key: controller.classSettingsKey,
|
||||
roomId: null,
|
||||
startOpen: true,
|
||||
initialSettings:
|
||||
Matrix.of(context).client.lastUpdatedClassSettings,
|
||||
),
|
||||
if (!controller.newClassMode)
|
||||
AddToSpaceToggles(
|
||||
|
|
@ -93,6 +97,7 @@ class NewSpaceView extends StatelessWidget {
|
|||
key: controller.rulesEditorKey,
|
||||
roomId: null,
|
||||
startOpen: false,
|
||||
initialRules: Matrix.of(context).client.lastUpdatedRoomRules,
|
||||
),
|
||||
// SwitchListTile.adaptive(
|
||||
// title: Text(L10n.of(context)!.spaceIsPublic),
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/constants/pangea_room_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/models/class_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../utils/p_store.dart';
|
||||
|
||||
extension PangeaClient on Client {
|
||||
|
|
@ -152,4 +152,21 @@ extension PangeaClient on Client {
|
|||
);
|
||||
return getRoomById(roomId)!;
|
||||
}
|
||||
|
||||
PangeaRoomRules? get lastUpdatedRoomRules => classesAndExchangesImTeaching
|
||||
.where((space) => space.rulesUpdatedAt != null)
|
||||
.sorted(
|
||||
(a, b) => b.rulesUpdatedAt!.compareTo(a.rulesUpdatedAt!),
|
||||
)
|
||||
.firstOrNull
|
||||
?.pangeaRoomRules;
|
||||
|
||||
ClassSettingsModel? get lastUpdatedClassSettings => classesImTeaching
|
||||
.where((space) => space.classSettingsUpdatedAt != null)
|
||||
.sorted(
|
||||
(a, b) =>
|
||||
b.classSettingsUpdatedAt!.compareTo(a.classSettingsUpdatedAt!),
|
||||
)
|
||||
.firstOrNull
|
||||
?.classSettings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/src/utils/space_child.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/constants/pangea_room_types.dart';
|
||||
|
|
@ -15,6 +8,12 @@ import 'package:fluffychat/pangea/models/class_model.dart';
|
|||
import 'package:fluffychat/pangea/models/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/src/utils/space_child.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../config/app_config.dart';
|
||||
import '../constants/pangea_event_types.dart';
|
||||
import '../enum/construct_type_enum.dart';
|
||||
|
|
@ -78,6 +77,8 @@ extension PangeaRoom on Room {
|
|||
|
||||
String? get creatorId => getState(EventTypes.RoomCreate)?.senderId;
|
||||
|
||||
DateTime? get creationTime => getState(EventTypes.RoomCreate)?.originServerTs;
|
||||
|
||||
ClassSettingsModel? get firstLanguageSettings =>
|
||||
classSettings ??
|
||||
firstParentWithState(PangeaEventTypes.classSettings)?.classSettings;
|
||||
|
|
@ -981,4 +982,14 @@ extension PangeaRoom on Room {
|
|||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
DateTime? get classSettingsUpdatedAt {
|
||||
if (!isSpace) return null;
|
||||
return languageSettingsStateEvent?.originServerTs ?? creationTime;
|
||||
}
|
||||
|
||||
DateTime? get rulesUpdatedAt {
|
||||
if (!isSpace) return null;
|
||||
return pangeaRoomRulesStateEvent?.originServerTs ?? creationTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import 'package:fluffychat/pangea/models/class_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/models/class_model.dart';
|
||||
import '../../../../config/app_config.dart';
|
||||
import '../../../../widgets/matrix.dart';
|
||||
import '../../../constants/pangea_event_types.dart';
|
||||
|
|
@ -14,12 +13,14 @@ class RoomRulesEditor extends StatefulWidget {
|
|||
final String? roomId;
|
||||
final bool startOpen;
|
||||
final bool showAdd;
|
||||
final PangeaRoomRules? initialRules;
|
||||
|
||||
const RoomRulesEditor({
|
||||
super.key,
|
||||
this.roomId,
|
||||
this.startOpen = true,
|
||||
this.showAdd = false,
|
||||
this.initialRules,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -43,7 +44,7 @@ class RoomRulesState extends State<RoomRulesEditor> {
|
|||
? Matrix.of(context).client.getRoomById(widget.roomId!)
|
||||
: null;
|
||||
|
||||
rules = room?.pangeaRoomRules ?? PangeaRoomRules();
|
||||
rules = room?.pangeaRoomRules ?? widget.initialRules ?? PangeaRoomRules();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/pangea/models/class_model.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/models/class_model.dart';
|
||||
import '../../../widgets/matrix.dart';
|
||||
import '../../constants/language_keys.dart';
|
||||
import '../../constants/language_level_type.dart';
|
||||
|
|
@ -24,8 +23,14 @@ import '../user_settings/p_question_container.dart';
|
|||
class ClassSettings extends StatefulWidget {
|
||||
final String? roomId;
|
||||
final bool startOpen;
|
||||
final ClassSettingsModel? initialSettings;
|
||||
|
||||
const ClassSettings({super.key, this.roomId, this.startOpen = false});
|
||||
const ClassSettings({
|
||||
super.key,
|
||||
this.roomId,
|
||||
this.startOpen = false,
|
||||
this.initialSettings,
|
||||
});
|
||||
|
||||
@override
|
||||
ClassSettingsState createState() => ClassSettingsState();
|
||||
|
|
@ -49,7 +54,8 @@ class ClassSettingsState extends State<ClassSettings> {
|
|||
? Matrix.of(context).client.getRoomById(widget.roomId!)
|
||||
: null;
|
||||
|
||||
classSettings = room?.classSettings ?? ClassSettingsModel();
|
||||
classSettings =
|
||||
room?.classSettings ?? widget.initialSettings ?? ClassSettingsModel();
|
||||
|
||||
isOpen = widget.startOpen;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue