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

Introducing Socialised Stories Updates #2537

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b050510
Created PostTo page for Add new flow and did required change related …
kumarpalsinh25 Jan 30, 2025
5d0316a
Minor Fix
kumarpalsinh25 Feb 3, 2025
c3ec2a0
PostTo screen design draft
kumarpalsinh25 Feb 3, 2025
a8ec33d
Merge branch 'main' into kumar/stories-update
kumarpalsinh25 Feb 13, 2025
a90e2bc
Update lang
kumarpalsinh25 Feb 13, 2025
2050742
Added Boost and Stories selection options
kumarpalsinh25 Feb 13, 2025
832cb22
Manage canPostBoost permission based on the selected space
kumarpalsinh25 Feb 13, 2025
a2efec1
Submit story implementation
kumarpalsinh25 Feb 14, 2025
6f659d5
Generalise code of MsgDraft
kumarpalsinh25 Feb 17, 2025
43d8f3a
Merge branch 'main' into kumar/stories-update
kumarpalsinh25 Feb 18, 2025
522c1ab
draft of abstract types
gnunicorn Feb 18, 2025
91ffef6
more draft of slides
gnunicorn Feb 18, 2025
ef7157a
stories providers draft
gnunicorn Feb 18, 2025
8c7db75
Updated abstract class for News and Story
kumarpalsinh25 Feb 19, 2025
fab262e
News and Story abstract class related changes
kumarpalsinh25 Feb 19, 2025
f8c409b
Fixed lint errors
kumarpalsinh25 Feb 19, 2025
f444715
Fixed lint errors
kumarpalsinh25 Feb 19, 2025
eceff2a
Merge branch 'main' into kumar/stories-update
kumarpalsinh25 Feb 19, 2025
9337f52
Fixed lint errors
kumarpalsinh25 Feb 19, 2025
16210c6
Added stories notifier and used it in updateList provider
kumarpalsinh25 Feb 19, 2025
4d19d34
More changes related to naming
kumarpalsinh25 Feb 19, 2025
9572bb2
Lint fix
kumarpalsinh25 Feb 19, 2025
b20c9dd
Added User name and Avtar for story update
kumarpalsinh25 Feb 19, 2025
42a2068
added sorting to update list
kumarpalsinh25 Feb 20, 2025
e18e30a
Optimised providers
kumarpalsinh25 Feb 20, 2025
4a247e9
Added Update Filter provider
kumarpalsinh25 Feb 20, 2025
038ae0d
Added filter chips for updates
kumarpalsinh25 Feb 20, 2025
c91fcc7
Changes in FilterChip design
kumarpalsinh25 Feb 20, 2025
2a018c3
Corrections in providers
kumarpalsinh25 Feb 20, 2025
dd85516
Code improvements
kumarpalsinh25 Feb 21, 2025
30082f6
Added missing L10n strings
kumarpalsinh25 Feb 21, 2025
f246177
Merge branch 'main' into kumar/stories-update
kumarpalsinh25 Feb 21, 2025
d8e8c11
Added post update validations
kumarpalsinh25 Feb 21, 2025
8a78093
Minor naming corrections
kumarpalsinh25 Feb 21, 2025
2c4a497
Minor UI correction
kumarpalsinh25 Feb 21, 2025
01786a8
Change the default of story permission to true
bitfriend Feb 21, 2025
048ee99
Added secondary can permission check in Select space drawer
kumarpalsinh25 Feb 21, 2025
b8acaa0
Updated default intilisation
kumarpalsinh25 Feb 21, 2025
f97e6d3
Fixes widget testing
kumarpalsinh25 Feb 21, 2025
179dc7a
Fixed lint error
kumarpalsinh25 Feb 21, 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
49 changes: 24 additions & 25 deletions app/integration_test/tests/updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:acter/common/utils/constants.dart';
import 'package:acter/features/home/data/keys.dart';
import 'package:acter/features/news/model/keys.dart';
import 'package:acter/features/news/model/news_slide_model.dart';
import 'package:acter/features/news/pages/add_news_page.dart';
import 'package:acter/features/news/pages/add_news/add_news_page.dart';
import 'package:acter/features/news/providers/news_post_editor_providers.dart';
import 'package:acter/features/search/model/keys.dart';
import 'package:acter/features/space/dialogs/leave_space.dart';
Expand Down Expand Up @@ -33,16 +33,15 @@ extension ActerNews on ConvenientTest {
}

Future<void> toggleBackgroundColor() async {
final slideBackgroundColorKey =
find.byKey(NewsUpdateKeys.slideBackgroundColor);
final slideBackgroundColorKey = find.byKey(UpdateKeys.slideBackgroundColor);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only name changes from NewsUpdateKeys to UpdateKeys

await slideBackgroundColorKey.should(findsOneWidget);
await slideBackgroundColorKey.tap();

await slideBackgroundColorKey.tap();
}

Future<EditorState> addTextSlide(String text) async {
final addTextSlideKey = find.byKey(NewsUpdateKeys.addTextSlide);
final addTextSlideKey = find.byKey(UpdateKeys.addTextSlide);
await addTextSlideKey.should(findsOneWidget);
await addTextSlideKey.tap();
final editorState = await _getNewsTextEditorState();
Expand All @@ -54,16 +53,16 @@ extension ActerNews on ConvenientTest {

Future<void> submitNews(String? spaceId) async {
if (spaceId != null) {
await selectSpace(spaceId, NewsUpdateKeys.selectSpace);
await selectSpace(spaceId, UpdateKeys.selectSpace);
}

final submit = find.byKey(NewsUpdateKeys.newsSubmitBtn);
final submit = find.byKey(UpdateKeys.newsSubmitBtn);
await tester.ensureVisible(submit);
await submit.tap();
}

Future<void> addImageSlide({String? filepath}) async {
final addImageSlideKey = find.byKey(NewsUpdateKeys.addImageSlide);
final addImageSlideKey = find.byKey(UpdateKeys.addImageSlide);
await addImageSlideKey.should(findsOneWidget);

// Adding Image Slide Object into Slide List
Expand All @@ -72,39 +71,39 @@ extension ActerNews on ConvenientTest {
final imageFile = await convertAssetImageToXFile(
filepath ?? 'assets/images/update_onboard.png',
);
final slide = NewsSlideItem(
type: NewsSlideType.image,
final slide = UpdateSlideItem(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only name changes from NewsSlideItem to UpdateSlideItem

type: UpdateSlideType.image,
mediaFile: imageFile,
);
ref.read(newsStateProvider.notifier).addSlide(slide);
}

Future<void> addVideoSlide({String? filepath}) async {
final addVideoSlideKey = find.byKey(NewsUpdateKeys.addVideoSlide);
final addVideoSlideKey = find.byKey(UpdateKeys.addVideoSlide);
await addVideoSlideKey.should(findsOneWidget);

// Adding Video Slide Object into Slide List
final context = tester.element(addVideoSlideKey);
final ref = ProviderScope.containerOf(context);
final videoFile =
await convertAssetImageToXFile(filepath ?? 'assets/videos/video.mp4');
final slide = NewsSlideItem(
type: NewsSlideType.video,
final slide = UpdateSlideItem(
type: UpdateSlideType.video,
mediaFile: videoFile,
);
ref.read(newsStateProvider.notifier).addSlide(slide);
}

Future<void> openAddSlide() async {
// Open bottom sheet for adding more slide
final addMoreNewsKey = find.byKey(NewsUpdateKeys.addNewsSlide);
final addMoreNewsKey = find.byKey(UpdateKeys.addNewsUpdate);
await addMoreNewsKey.should(findsOneWidget);
await addMoreNewsKey.tap();
}

Future<void> closeAddSlide() async {
// Close bottom sheet
final cancelKey = find.byKey(NewsUpdateKeys.cancelButton);
final cancelKey = find.byKey(UpdateKeys.cancelButton);
await cancelKey.should(findsOneWidget);
await cancelKey.tap();
}
Expand All @@ -121,7 +120,7 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final textUpdateContent = find.byKey(NewsUpdateKeys.textUpdateContent);
final textUpdateContent = find.byKey(UpdateKeys.textUpdateContent);
await textUpdateContent.should(findsOneWidget);
await find.text(text).should(findsWidgets);
});
Expand Down Expand Up @@ -156,7 +155,7 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final textUpdateContent = find.byKey(NewsUpdateKeys.textUpdateContent);
final textUpdateContent = find.byKey(UpdateKeys.textUpdateContent);
await textUpdateContent.should(findsOneWidget);
await find.text(text).should(findsOneWidget);
await find
Expand All @@ -174,7 +173,7 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent);
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent);
await imageUpdateContent.should(findsOneWidget);
});

Expand All @@ -187,7 +186,7 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent);
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent);
await imageUpdateContent.should(findsOneWidget);
await t.gotoSpace(spaceId);
await t.navigateTo([
Expand All @@ -209,7 +208,7 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final videoUpdateContent = find.byKey(NewsUpdateKeys.videoNewsContent);
final videoUpdateContent = find.byKey(UpdateKeys.videoNewsContent);
await videoUpdateContent.should(findsOneWidget);
});

Expand All @@ -233,7 +232,7 @@ void updateTests() {

await t.submitNews(null); // no space selected, this will fail
// so we select a space
await t.selectSpace(spaceId, NewsUpdateKeys.selectSpace);
await t.selectSpace(spaceId, UpdateKeys.selectSpace);
await t.submitNews(null); // text is empty, so this will fail

await t.trigger(
Expand All @@ -256,7 +255,7 @@ void updateTests() {

// we expect to be thrown to the news screen and see our latest item first:
// For Image
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent);
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent);
await imageUpdateContent.should(findsOneWidget);
});

Expand All @@ -269,16 +268,16 @@ void updateTests() {
await t.submitNews(spaceId);

// we expect to be thrown to the news screen and see our latest item first:
final imageUpdateContent = find.byKey(NewsUpdateKeys.imageUpdateContent);
final imageUpdateContent = find.byKey(UpdateKeys.imageUpdateContent);
await imageUpdateContent.should(findsOneWidget);

// open news sidebar bottom sheet for action buttons
await t.trigger(NewsUpdateKeys.newsSidebarActionBottomSheet);
await t.trigger(UpdateKeys.newsSidebarActionBottomSheet);

// click on remove button for show confirm dialog
await t.trigger(NewsUpdateKeys.newsSidebarActionRemoveBtn);
await t.trigger(UpdateKeys.newsSidebarActionRemoveBtn);

// click on remove button
await t.trigger(NewsUpdateKeys.removeButton);
await t.trigger(UpdateKeys.removeButton);
});
}
1 change: 1 addition & 0 deletions app/lib/common/utils/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum Routes {
update('/updates/:updateId([^/]+)'),
updateList('/updateList'),
actionAddUpdate('/actions/addUpdate'),
actionAddUpdatePostTo('/actions/addUpdate/PostTo'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new PostTo screen as show-case in PR Description


// --- search
searchPublicDirectory('/search/public'),
Expand Down
6 changes: 5 additions & 1 deletion app/lib/common/widgets/space_name_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
class SpaceNameWidget extends ConsumerWidget {
final String spaceId;
final bool isShowBrackets;
final bool isShowUnderline;

const SpaceNameWidget({
super.key,
required this.spaceId,
this.isShowBrackets = true,
this.isShowUnderline = false,
});

@override
Expand All @@ -25,7 +27,9 @@ class SpaceNameWidget extends ConsumerWidget {
spaceName,
overflow: TextOverflow.ellipsis,
maxLines: 3,
style: Theme.of(context).textTheme.labelLarge,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
decoration: isShowUnderline ? TextDecoration.underline : null,
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final commentsListProvider = FutureProvider.family
return commentList;
});

final newsCommentsCountProvider = FutureProvider.family
final updateCommentsCountProvider = FutureProvider.family
.autoDispose<int, CommentsManagerProvider>((ref, managerProvider) async {
final commentManager =
await ref.watch(commentsManagerProvider(managerProvider).future);
Expand Down
17 changes: 9 additions & 8 deletions app/lib/features/comments/types.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:acter/features/news/model/type/update_entry.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart'
show ActerPin, CalendarEvent, CommentsManager, NewsEntry, Task, TaskList;
show ActerPin, CalendarEvent, CommentsManager, Task, TaskList;

/// This is the actual input type for the providers and widget of this feature
/// the way to get this is through implementing a "wrapper" type for the getter
Expand Down Expand Up @@ -57,11 +58,11 @@
TaskCommentsManagerProvider(this);
}

class NewsEntryCommentsManagerProvider implements CommentsManagerProvider {
final NewsEntry inner;
class UpdateEntryCommentsManagerProvider implements CommentsManagerProvider {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming changes only.

final UpdateEntry inner;
late String innerId;

NewsEntryCommentsManagerProvider(this.inner) {
UpdateEntryCommentsManagerProvider(this.inner) {

Check warning on line 65 in app/lib/features/comments/types.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/comments/types.dart#L65

Added line #L65 was not covered by tests
innerId = inner.eventId().toString();
}

Expand All @@ -72,12 +73,12 @@
int get hashCode => innerId.hashCode;
@override
bool operator ==(other) =>
other is NewsEntryCommentsManagerProvider && innerId == other.innerId;
other is UpdateEntryCommentsManagerProvider && innerId == other.innerId;

Check warning on line 76 in app/lib/features/comments/types.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/comments/types.dart#L76

Added line #L76 was not covered by tests
}

extension NewsEntryCommentsManagerProviderExtension on NewsEntry {
NewsEntryCommentsManagerProvider asCommentsManagerProvider() =>
NewsEntryCommentsManagerProvider(this);
extension UpdateEntryCommentsManagerProviderExtension on UpdateEntry {
UpdateEntryCommentsManagerProvider asCommentsManagerProvider() =>
UpdateEntryCommentsManagerProvider(this);

Check warning on line 81 in app/lib/features/comments/types.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/comments/types.dart#L80-L81

Added lines #L80 - L81 were not covered by tests
}

class ActerPinCommentsManagerProvider implements CommentsManagerProvider {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/features/main/app_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
// the content is being fetched and cached
ref.read(spacesProvider);
ref.read(chatsProvider);
ref.read(newsListProvider(null));
ref.read(updateListProvider(null));

Check warning on line 83 in app/lib/features/main/app_shell.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/main/app_shell.dart#L83

Added line #L83 was not covered by tests
ref.read(hasActivitiesProvider);
}

Expand Down
78 changes: 78 additions & 0 deletions app/lib/features/news/actions/make_image_slide.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:acter/common/providers/sdk_provider.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/features/home/providers/client_providers.dart';
import 'package:acter/features/news/model/news_slide_model.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mime/mime.dart';

Future<NewsSlideDraft> makeImageSlideForNews(

Check warning on line 12 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L12

Added line #L12 was not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No logical changes. Just copied logic from previous implementation and used it based on the post type.

WidgetRef ref,
UpdateSlideItem slidePost,
L10n lang,
) async {
final imageDraft = await createImageMsgDraftDraft(ref, slidePost, lang);
final imageSlideDraft = imageDraft.intoNewsSlideDraft();

Check warning on line 18 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L17-L18

Added lines #L17 - L18 were not covered by tests

final sdk = await ref.read(sdkProvider.future);
imageSlideDraft.color(
sdk.api.newColorizeBuilder(null, slidePost.backgroundColor?.toInt()),

Check warning on line 22 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L20-L22

Added lines #L20 - L22 were not covered by tests
);

final refDetails = slidePost.refDetails;

Check warning on line 25 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L25

Added line #L25 was not covered by tests
if (refDetails != null) {
final objRefBuilder = sdk.api.newObjRefBuilder(null, refDetails);
imageSlideDraft.addReference(objRefBuilder);

Check warning on line 28 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L27-L28

Added lines #L27 - L28 were not covered by tests
}
return imageSlideDraft;
}

Future<StorySlideDraft> makeImageSlideForStory(

Check warning on line 33 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L33

Added line #L33 was not covered by tests
WidgetRef ref,
UpdateSlideItem slidePost,
L10n lang,
) async {
final imageDraft = await createImageMsgDraftDraft(ref, slidePost, lang);
final imageSlideDraft = imageDraft.intoStorySlideDraft();

Check warning on line 39 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L38-L39

Added lines #L38 - L39 were not covered by tests

final sdk = await ref.read(sdkProvider.future);
imageSlideDraft.color(
sdk.api.newColorizeBuilder(null, slidePost.backgroundColor?.toInt()),

Check warning on line 43 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L41-L43

Added lines #L41 - L43 were not covered by tests
);

final refDetails = slidePost.refDetails;

Check warning on line 46 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L46

Added line #L46 was not covered by tests
if (refDetails != null) {
final objRefBuilder = sdk.api.newObjRefBuilder(null, refDetails);
imageSlideDraft.addReference(objRefBuilder);

Check warning on line 49 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L48-L49

Added lines #L48 - L49 were not covered by tests
}
return imageSlideDraft;
}

Future<MsgDraft> createImageMsgDraftDraft(

Check warning on line 54 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L54

Added line #L54 was not covered by tests
WidgetRef ref,
UpdateSlideItem slidePost,
L10n lang,
) async {
final client = await ref.read(alwaysClientProvider.future);

Check warning on line 59 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L59

Added line #L59 was not covered by tests

final file = slidePost.mediaFile;

Check warning on line 61 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L61

Added line #L61 was not covered by tests
if (file == null) {
throw 'Image File missing';
}
String? mimeType = file.mimeType ?? lookupMimeType(file.path);
if (mimeType == null) throw lang.failedToDetectMimeType;
if (!mimeType.startsWith('image/')) {
throw lang.postingOfTypeNotYetSupported(mimeType);

Check warning on line 68 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L65-L68

Added lines #L65 - L68 were not covered by tests
}
Uint8List bytes = await file.readAsBytes();
final decodedImage = await decodeImageFromList(bytes);

Check warning on line 71 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L70-L71

Added lines #L70 - L71 were not covered by tests
final imageDraft = client
.imageDraft(file.path, mimeType)
.size(bytes.length)
.width(decodedImage.width)
.height(decodedImage.height);

Check warning on line 76 in app/lib/features/news/actions/make_image_slide.dart

View check run for this annotation

Codecov / codecov/patch

app/lib/features/news/actions/make_image_slide.dart#L73-L76

Added lines #L73 - L76 were not covered by tests
return imageDraft;
}
Loading
Loading