Skip to content

Commit

Permalink
TW-902: Move Chat details in go_router to inner router
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Dec 18, 2023
1 parent beec60b commit 331b881
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 114 deletions.
4 changes: 1 addition & 3 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2964,7 +2964,5 @@
"description": "Description",
"groupName": "Group name",
"descriptionHelper": "You can provide an optional description for your group.",
"errorUploadingGroupName": "Error uploading group name.",
"errorUploadingGroupDescription": "Error uploading group description.",
"errorUploadingGroupAvatar": "Error uploading group avatar."
"groupNameCannotBeEmpty": "Group name cannot be empty"
}
6 changes: 3 additions & 3 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ target 'Runner' do

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

# target 'Twake Share' do
# inherit! :search_paths
# end
target 'Twake Share' do
inherit! :search_paths
end
end

post_install do |installer|
Expand Down
46 changes: 41 additions & 5 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
C1005C45261071B5002F4F32 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1005C44261071B5002F4F32 /* ShareViewController.swift */; };
C1005C4C261071B5002F4F32 /* Twake Share.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = C1005C42261071B5002F4F32 /* Twake Share.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
C149567C25C7274F00A16396 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C149567B25C7274F00A16396 /* GoogleService-Info.plist */; };
E388818A944B178F69E4431D /* Pods_Twake_Share.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB50B9422955BF92FC0FEB3C /* Pods_Twake_Share.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -270,6 +271,8 @@
1B6C59111A74FF0BB750A10A /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
216064C73ECC2AECB9F0A1FA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3D818CE626126D8D1C67A3C9 /* Pods-Twake Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Twake Share.release.xcconfig"; path = "Target Support Files/Pods-Twake Share/Pods-Twake Share.release.xcconfig"; sourceTree = "<group>"; };
48F3E70A44AA65D69E70C12D /* Pods-Twake Share.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Twake Share.profile.xcconfig"; path = "Target Support Files/Pods-Twake Share/Pods-Twake Share.profile.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand All @@ -281,12 +284,14 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B16AB66899BBD65C9BFB2599 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BD7FC81DBDE4B0D093DEFFCB /* Pods-Twake Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Twake Share.debug.xcconfig"; path = "Target Support Files/Pods-Twake Share/Pods-Twake Share.debug.xcconfig"; sourceTree = "<group>"; };
C1005C42261071B5002F4F32 /* Twake Share.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Twake Share.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
C1005C44261071B5002F4F32 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
C1005C49261071B5002F4F32 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C1005C53261072D4002F4F32 /* Twake Share.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Twake Share.entitlements"; sourceTree = "<group>"; };
C149567B25C7274F00A16396 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
C149567D25C7276200A16396 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
DB50B9422955BF92FC0FEB3C /* Pods_Twake_Share.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Twake_Share.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FDBA7311CF00074CB7786C33 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -320,6 +325,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E388818A944B178F69E4431D /* Pods_Twake_Share.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -452,6 +458,7 @@
isa = PBXGroup;
children = (
B16AB66899BBD65C9BFB2599 /* Pods_Runner.framework */,
DB50B9422955BF92FC0FEB3C /* Pods_Twake_Share.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -524,6 +531,9 @@
1B6C59111A74FF0BB750A10A /* Pods-Runner.debug.xcconfig */,
FDBA7311CF00074CB7786C33 /* Pods-Runner.release.xcconfig */,
216064C73ECC2AECB9F0A1FA /* Pods-Runner.profile.xcconfig */,
BD7FC81DBDE4B0D093DEFFCB /* Pods-Twake Share.debug.xcconfig */,
3D818CE626126D8D1C67A3C9 /* Pods-Twake Share.release.xcconfig */,
48F3E70A44AA65D69E70C12D /* Pods-Twake Share.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand Down Expand Up @@ -589,6 +599,7 @@
isa = PBXNativeTarget;
buildConfigurationList = C1005C51261071B5002F4F32 /* Build configuration list for PBXNativeTarget "Twake Share" */;
buildPhases = (
265995452BC4DC2D49CADCC6 /* [CP] Check Pods Manifest.lock */,
C1005C3E261071B5002F4F32 /* Sources */,
C1005C3F261071B5002F4F32 /* Frameworks */,
C1005C40261071B5002F4F32 /* Resources */,
Expand Down Expand Up @@ -663,9 +674,9 @@
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
06EA9CA02B21CFC000351529 /* XCRemoteSwiftPackageReference "DTCoreText" */,
06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit.git" */,
06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit" */,
06EA9CA62B21D13300351529 /* XCRemoteSwiftPackageReference "matrix-rust-components-swift" */,
06EA9CA92B21D17200351529 /* XCLocalSwiftPackageReference "DesignKit" */,
06EA9CA92B21D17200351529 /* XCLocalSwiftPackageReference "NSE/DesignKit" */,
06EA9CAC2B21D2CA00351529 /* XCRemoteSwiftPackageReference "LRUCache" */,
06EA9CAF2B21D2FE00351529 /* XCRemoteSwiftPackageReference "KeychainAccess" */,
06EA9CB22B21D33700351529 /* XCRemoteSwiftPackageReference "Kingfisher" */,
Expand Down Expand Up @@ -716,6 +727,28 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
265995452BC4DC2D49CADCC6 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Twake Share-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -1403,6 +1436,7 @@
};
C1005C4E261071B5002F4F32 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BD7FC81DBDE4B0D093DEFFCB /* Pods-Twake Share.debug.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1443,6 +1477,7 @@
};
C1005C4F261071B5002F4F32 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3D818CE626126D8D1C67A3C9 /* Pods-Twake Share.release.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1480,6 +1515,7 @@
};
C1005C50261071B5002F4F32 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 48F3E70A44AA65D69E70C12D /* Pods-Twake Share.profile.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1561,7 +1597,7 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
06EA9CA92B21D17200351529 /* XCLocalSwiftPackageReference "DesignKit" */ = {
06EA9CA92B21D17200351529 /* XCLocalSwiftPackageReference "NSE/DesignKit" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = NSE/DesignKit;
};
Expand Down Expand Up @@ -1600,7 +1636,7 @@
version = 1.6.26;
};
};
06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit.git" */ = {
06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/devicekit/DeviceKit.git";
requirement = {
Expand Down Expand Up @@ -1665,7 +1701,7 @@
};
06EA9CA42B21D09D00351529 /* DeviceKit */ = {
isa = XCSwiftPackageProductDependency;
package = 06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit.git" */;
package = 06EA9CA32B21D09D00351529 /* XCRemoteSwiftPackageReference "DeviceKit" */;
productName = DeviceKit;
};
06EA9CA72B21D13300351529 /* MatrixRustSDK */ = {
Expand Down
44 changes: 0 additions & 44 deletions lib/config/go_routes/go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,50 +435,6 @@ abstract class AppRoutes {
),
redirect: loggedOutRedirect,
),
// GoRoute(
// path: 'details',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// ChatDetails(
// roomId: state.pathParameters['roomid']!,
// ),
// ),
// routes: [
// GoRoute(
// path: 'permissions',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// const ChatPermissionsSettings(),
// ),
// redirect: loggedOutRedirect,
// ),
// GoRoute(
// path: 'multiple_emotes',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// const MultipleEmotesSettings(),
// ),
// redirect: loggedOutRedirect,
// ),
// GoRoute(
// path: 'emotes',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// const EmotesSettings(),
// ),
// redirect: loggedOutRedirect,
// ),
// GoRoute(
// path: 'emotes/:state_key',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// const EmotesSettings(),
// ),
// redirect: loggedOutRedirect,
// ),
// ],
// redirect: loggedOutRedirect,
// ),
],
),
],
Expand Down
22 changes: 18 additions & 4 deletions lib/domain/app_state/room/update_group_chat_failure.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:fluffychat/app_state/failure.dart';
import 'package:matrix/matrix.dart';

class UpdateGroupChatFailure extends Failure {
final dynamic exception;
final MatrixException exception;

const UpdateGroupChatFailure(this.exception) : super();

Expand All @@ -12,7 +13,9 @@ class UpdateGroupChatFailure extends Failure {
class UpdateGroupAvatarFailure extends Failure {
final dynamic exception;

const UpdateGroupAvatarFailure(this.exception) : super();
const UpdateGroupAvatarFailure({
this.exception,
}) : super();

@override
List<Object?> get props => [exception];
Expand All @@ -21,7 +24,9 @@ class UpdateGroupAvatarFailure extends Failure {
class UpdateGroupDisplayNameFailure extends Failure {
final dynamic exception;

const UpdateGroupDisplayNameFailure(this.exception) : super();
const UpdateGroupDisplayNameFailure({
this.exception,
}) : super();

@override
List<Object?> get props => [exception];
Expand All @@ -30,8 +35,17 @@ class UpdateGroupDisplayNameFailure extends Failure {
class UpdateGroupDescriptionFailure extends Failure {
final dynamic exception;

const UpdateGroupDescriptionFailure(this.exception) : super();
const UpdateGroupDescriptionFailure({
this.exception,
}) : super();

@override
List<Object?> get props => [exception];
}

class UpdateGroupNameIsEmptyFailure extends Failure {
const UpdateGroupNameIsEmptyFailure() : super();

@override
List<Object?> get props => [];
}
64 changes: 47 additions & 17 deletions lib/domain/usecase/room/update_group_chat_interactor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,50 @@ class UpdateGroupChatInteractor {
},
);
yield Right(UpdateAvatarGroupChatSuccess(isDeleteAvatar));
} on MatrixException catch (error) {
Logs().e(
'UpdateGroupChatInteractor::_updateAvatarForRoom(): ErrorCode ${error.errcode} - ErrorMessage ${error.errorMessage}',
);
yield Left(
UpdateGroupChatFailure(error),
);
return;
} catch (e) {
Logs().e('UpdateGroupChatInteractor::_updateAvatarForRoom(): $e');
yield Left(UpdateGroupAvatarFailure(e));
yield Left(UpdateGroupAvatarFailure(exception: e));
return;
}
}
if (displayName != null && displayName != room.name) {
try {
await client.setRoomStateWithKey(
room.id,
EventTypes.RoomName,
'',
{
'name': displayName,
},
);
yield const Right(UpdateDisplayNameGroupChatSuccess());
} catch (e) {
Logs().e('UpdateGroupChatInteractor::_updateDisplayNameForRoom(): $e');
yield Left(UpdateGroupDisplayNameFailure(e));
return;
if (displayName != null) {
if (displayName != room.name) {
try {
await client.setRoomStateWithKey(
room.id,
EventTypes.RoomName,
'',
{
'name': displayName,
},
);
yield const Right(UpdateDisplayNameGroupChatSuccess());
} on MatrixException catch (error) {
Logs().e(
'UpdateGroupChatInteractor::_updateDisplayNameForRoom(): ErrorCode ${error.errcode} - ErrorMessage ${error.errorMessage}',
);
yield Left(
UpdateGroupChatFailure(error),
);
return;
} catch (e) {
Logs()
.e('UpdateGroupChatInteractor::_updateDisplayNameForRoom(): $e');
yield Left(UpdateGroupDisplayNameFailure(exception: e));
return;
}
}
} else {
yield const Left(UpdateGroupNameIsEmptyFailure());
return;
}

if (description != null && description != room.topic) {
Expand All @@ -63,9 +85,17 @@ class UpdateGroupChatInteractor {
},
);
yield const Right(UpdateDescriptionGroupChatSuccess());
} on MatrixException catch (error) {
Logs().e(
'UpdateGroupChatInteractor::_updateDescriptionForRoom(): ErrorCode ${error.errcode} - ErrorMessage ${error.errorMessage}',
);
yield Left(
UpdateGroupChatFailure(error),
);
return;
} catch (e) {
Logs().e('UpdateGroupChatInteractor::_updateDescriptionForRoom(): $e');
yield Left(UpdateGroupDescriptionFailure(e));
yield Left(UpdateGroupDescriptionFailure(exception: e));
return;
}
}
Expand Down
6 changes: 0 additions & 6 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ class ChatController extends State<Chat>
EventTypes.Sticker,
EventTypes.Encrypted,
EventTypes.CallInvite,
EventTypes.RoomAvatar,
EventTypes.RoomName,
EventTypes.RoomTopic,
}.contains(event.type),
);

Expand Down Expand Up @@ -367,9 +364,6 @@ class ChatController extends State<Chat>
loadTimelineFuture = _getTimeline();
try {
await loadTimelineFuture;
if ((timeline?.events.length ?? 0) < _loadHistoryCount) {
requestFuture();
}
final fullyRead = room?.fullyRead;
if (fullyRead == null || fullyRead.isEmpty || fullyRead == '') {
setReadMarker();
Expand Down
Loading

0 comments on commit 331b881

Please sign in to comment.