Skip to content
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

New Room Preview facilities #2373

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
99b5caf
New Room Preview facilities
gnunicorn Nov 15, 2024
bc11c77
Starting out with preview builder
gnunicorn Nov 18, 2024
8d6c425
Add avatar loading support
gnunicorn Nov 18, 2024
83783fb
actions
gnunicorn Nov 18, 2024
81944e0
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Nov 22, 2024
db8e099
Improved error messages text builder
gnunicorn Nov 22, 2024
19bfd33
Fix room preview query facilities
gnunicorn Nov 22, 2024
c298c3f
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Dec 4, 2024
4f0b82f
Post-merge test fixes
gnunicorn Dec 4, 2024
62e5577
remove unnecessary provider
gnunicorn Dec 4, 2024
b6ab9a0
Merge branch 'ben-check-singleton-in-release-only' into ben-room-prev…
gnunicorn Dec 4, 2024
43d5ccb
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Dec 8, 2024
f4aebfc
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Dec 30, 2024
55a420a
More preview for invites
gnunicorn Dec 30, 2024
8ab10ee
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 7, 2025
bed4c20
expose missing api fn
gnunicorn Jan 9, 2025
0b5f89a
Link RoomPreview to shared objects
gnunicorn Jan 9, 2025
76c3b8a
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 10, 2025
753abc4
Common preview item card for items from unknown rooms
gnunicorn Jan 12, 2025
9b57e61
Join buttons on preview
gnunicorn Jan 12, 2025
f2036f9
remove join room forwarding param
gnunicorn Jan 12, 2025
26f9214
Fixing up join and forward to selected item
gnunicorn Jan 12, 2025
7842344
Fix room preview tests
gnunicorn Jan 14, 2025
703d7f6
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 14, 2025
d3e9516
remove comment
gnunicorn Jan 14, 2025
6f967c8
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 19, 2025
018d2d6
Adding changelog
gnunicorn Jan 19, 2025
013111b
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 21, 2025
97ec8e1
Merge remote-tracking branch 'origin/main' into ben-room-previews
gnunicorn Jan 21, 2025
5bce726
remove double line in faulty merge
gnunicorn Jan 21, 2025
2d5d2cd
alwaysClientProvider is now async
gnunicorn Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/2373-room-previews.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Will we now show you a preview of the space when you try to access an object you don't have access to you yet with the ability to let you quickly join the space and interact with the object
- We are now showing a Room Preview with additional information when you click on the title in an invite
- the QR Code for objects now shows you the details that will be shared with the reader
- A fix has been made when joining required to go through more than one server
- We are now sharing our own target server in the via-parameter of shared links
2 changes: 1 addition & 1 deletion app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.7.1' apply false
id "com.android.application" version '8.7.3' apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
id "com.google.gms.google-services" version "4.4.2" apply false
}
Expand Down
29 changes: 29 additions & 0 deletions app/lib/common/extensions/record_helpers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// AllHashed is a helper for record-types to ensure they are cached
/// properly by riverpod.
///
/// When giving a record e.g. `typedef query = ({String roomIdOrAlias, List<String> serverNames});`
/// as the parameter to a riverpod provider, the latter `List<String>` will
/// have different hashes for every instance created. This means that even if
/// both are `List.empty()` riverpod doesn't recognise them as the same and will
/// run the provider again, cluttering up memory as well as unnecessary computation
///
/// This type, given a list of items `T` will always return the same hash for the
/// same items.
class AllHashed<T> {
final List<T> items;

AllHashed(this.items);

@override
int get hashCode => Object.hashAll(items);

@override
bool operator ==(Object other) {
if (other is AllHashed<T>) {
return items == other.items;
} else if (other is List<T>) {
return items == other;
}
return false;
}
}
Comment on lines +12 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not understanding this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two list of items, even if they are all the same, will come out as "different" if they are different instances. This is used to ensure that https://github.com/acterglobal/a3/pull/2373/files#diff-b2a403334550e3f97cc376cf1228271526121ca2ecf70cf62e6c50ba41e69289R14 caches the input value and not keeps triggering for every render.

36 changes: 0 additions & 36 deletions app/lib/common/toolkit/buttons/room_chip.dart

This file was deleted.

13 changes: 9 additions & 4 deletions app/lib/common/toolkit/errors/error_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ActerErrorDialog extends StatelessWidget {

final String? title;
final String? text;
final String Function(Object error)? textBuilder;
final ErrorTextBuilder? textBuilder;
final bool includeBugReportButton;

/// Dialog Border Radius
Expand Down Expand Up @@ -48,7 +48,7 @@ class ActerErrorDialog extends StatelessWidget {
/// Text of the dialog
String? text,
VoidCallback? onRetryTap,
String Function(Object error)? textBuilder,
ErrorTextBuilder? textBuilder,
bool includeBugReportButton = true,

/// Dialog Border Radius
Expand Down Expand Up @@ -88,18 +88,23 @@ class ActerErrorDialog extends StatelessWidget {
title: title ??
switch (err) {
ErrorCode.notFound => lang.notFound,
ErrorCode.forbidden => lang.forbidden,
_ => lang.fatalError,
},
text: text ?? textBuilder.map((cb) => cb(error)),
text: text ?? textBuilder.map((cb) => cb(error, err)),
type: switch (err) {
ErrorCode.notFound => QuickAlertType.warning,
ErrorCode.notFound ||
ErrorCode.forbidden ||
ErrorCode.unknown =>
QuickAlertType.warning,
_ => QuickAlertType.error,
},
showCancelBtn: true,
showConfirmBtn: false,
cancelBtnText: lang.back,
borderRadius: borderRadius,
);

onRetryTap.map((cb) {
options.showConfirmBtn = true;
options.confirmBtnColor = theme.primaryColor;
Expand Down
3 changes: 2 additions & 1 deletion app/lib/common/toolkit/errors/error_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:acter/common/toolkit/errors/error_dialog.dart';
import 'package:acter/common/toolkit/errors/util.dart';
import 'package:flutter/material.dart';

/// ErrorPage shows a full-screen error to the user (covering other internal errors)
Expand All @@ -14,7 +15,7 @@ class ErrorPage extends StatelessWidget {

final String? title;
final String? text;
final String Function(Object error)? textBuilder;
final ErrorTextBuilder? textBuilder;
final bool includeBugReportButton;

/// Dialog Border Radius
Expand Down
3 changes: 2 additions & 1 deletion app/lib/common/toolkit/errors/inline_error_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:acter/common/extensions/options.dart';
import 'package:acter/common/toolkit/errors/error_dialog.dart';
import 'package:acter/common/toolkit/errors/util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

Expand All @@ -17,7 +18,7 @@ class ActerInlineErrorButton extends StatelessWidget {

final String? dialogTitle;
final String? text;
final String Function(Object error)? textBuilder;
final ErrorTextBuilder? textBuilder;
final bool includeBugReportButton;

const ActerInlineErrorButton({
Expand Down
8 changes: 8 additions & 0 deletions app/lib/common/toolkit/errors/util.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
typedef ErrorTextBuilder = String Function(Object error, ErrorCode code);

enum ErrorCode {
notFound,
forbidden,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended the Error types to be more specific and more precise and allow us to show a different error depending on the underlying code we were given by the server: most notably if we were forbidden access.

unknown,
other;

static ErrorCode guessFromError(Object error) {
final errorStr = error.toString();
// yay, string-based error guessing!
if (errorStr.contains('not found')) {
return ErrorCode.notFound;
} else if (errorStr.contains('[400 / UNKNOWN]')) {
return ErrorCode.unknown;
} else if (errorStr.contains('[403 / M_FORBIDDEN]')) {
return ErrorCode.forbidden;
Comment on lines +14 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errorStr will contains exact [400 / UNKNOWN]?

If not then how about making condition like if (errorStr.contains('400') || errorStr.contains('UNKNOWN'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is exact on purpose.

}
return ErrorCode.other;
}
Expand Down
4 changes: 4 additions & 0 deletions app/lib/common/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ List<String> asDartStringList(FfiListFfiString data) {
return data.toList().map((e) => e.toDartString()).toList();
}

extension FfiListFfiStringtoDart on FfiListFfiString {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made this more accessible via helper extension

List<String> toDart() => asDartStringList(this);
}

double? calcGap(BuildContext context) {
// ignore: deprecated_member_use
final double scale = MediaQuery.textScalerOf(context).textScaleFactor;
Expand Down
48 changes: 0 additions & 48 deletions app/lib/common/widgets/reference_details_item.dart

This file was deleted.

34 changes: 19 additions & 15 deletions app/lib/common/widgets/room/room_hierarchy_join_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RoomHierarchyJoinButton extends ConsumerWidget {
final String roomId;
final String joinRule;
final String roomName;
final String? viaServerName;
final List<String>? viaServerName;

const RoomHierarchyJoinButton({
super.key,
Expand Down Expand Up @@ -42,14 +42,16 @@ class RoomHierarchyJoinButton extends ConsumerWidget {
message: lang.youAreAbleToJoinThisRoom,
child: OutlinedButton(
onPressed: () async {
await joinRoom(
context,
ref,
lang.tryingToJoin(roomName),
roomId,
viaServerName,
forward,
final newRoomId = await joinRoom(
context: context,
ref: ref,
roomIdOrAlias: roomId,
serverNames: viaServerName,
roomName: roomName,
);
if (newRoomId != null) {
forward(newRoomId);
}
},
child: Text(lang.join),
),
Expand All @@ -58,14 +60,16 @@ class RoomHierarchyJoinButton extends ConsumerWidget {
message: lang.youAreAbleToJoinThisRoom,
child: OutlinedButton(
onPressed: () async {
await joinRoom(
context,
ref,
lang.tryingToJoin(roomName),
roomId,
viaServerName,
forward,
final newRoomId = await joinRoom(
context: context,
ref: ref,
roomIdOrAlias: roomId,
serverNames: viaServerName,
roomName: roomName,
);
if (newRoomId != null) {
forward(newRoomId);
}
},
child: Text(lang.join),
),
Expand Down
6 changes: 4 additions & 2 deletions app/lib/features/chat/pages/sub_chats_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/providers/space_providers.dart';
import 'package:acter/common/skeletons/general_list_skeleton_widget.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/common/widgets/room/room_card.dart';
import 'package:acter/common/widgets/room/room_hierarchy_card.dart';
import 'package:acter/common/widgets/room/room_hierarchy_join_button.dart';
Expand All @@ -11,6 +12,7 @@ import 'package:acter/features/categories/providers/categories_providers.dart';
import 'package:acter/features/categories/widgets/category_header_view.dart';
import 'package:acter/features/chat/providers/chat_providers.dart';
import 'package:acter/router/utils.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -167,7 +169,7 @@ class SubChatsPage extends ConsumerWidget {
[];
final remoteSubchats =
ref.watch(remoteChatRelationsProvider(spaceId)).valueOrNull ?? [];
final entries = [];
final List<(SpaceHierarchyRoomInfo?, String)> entries = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being specific in types allows the dart compiler to figure out the type below isn't correct.


for (final subId in categoryModelLocal.entries) {
if (knownChats.contains(subId)) {
Expand Down Expand Up @@ -229,7 +231,7 @@ class SubChatsPage extends ConsumerWidget {
joinRule: roomInfo.joinRuleStr().toLowerCase(),
roomId: roomId,
roomName: roomInfo.name() ?? roomId,
viaServerName: roomInfo.viaServerName(),
viaServerName: roomInfo.viaServerNames().toDart(),
forward: (spaceId) {
goToChat(context, spaceId);
ref.invalidate(spaceRelationsProvider(parentId));
Expand Down
Loading
Loading