Skip to content

Conversation

@ManhNTX
Copy link
Collaborator

@ManhNTX ManhNTX commented Jan 18, 2023

No description provided.

@ManhNTX ManhNTX temporarily deployed to dev January 18, 2023 04:03 — with GitHub Actions Inactive
@ManhNTX ManhNTX temporarily deployed to dev January 18, 2023 04:03 — with GitHub Actions Inactive
@hoangdat
Copy link
Member

hoangdat commented Jan 19, 2023

  1. How about the use-case layer?
  2. How about to use Either?

@hoangdat
Copy link
Member

  1. Why need BaseMessageBloc? ``Base... Base...`


part 'base_message_event.dart';

part 'base_message_state.dart';
Copy link
Member

Choose a reason for hiding this comment

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

It is recommended to use absolute path

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! Thanks for the work, now everything is done on сubits and I don't see the point in adding new blocks with events, it's better to keep everything on сubits IMHO

final threadId = event.threadId ?? Globals.instance.threadId;

List<Message> lastList = const [];
await for (var list in stream) {
Copy link
Member

Choose a reason for hiding this comment

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

IMO, Should be split into smaller functions


emit(MessagesLoadSuccess(
messages: list,
hash: list.fold(0, (acc, m) => acc + m.hash),
Copy link
Member

Choose a reason for hiding this comment

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

IMO, Create function to generate hash key

});

@override
List<Object?> get props => [];
Copy link
Member

Choose a reason for hiding this comment

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

IMO, properties should be added to props for future comparison.

Duration(milliseconds: 50),
FocusManager.instance.primaryFocus?.unfocus,
);
Get.find<MessageAnimationCubit>().endAnimation();
Copy link
Member

Choose a reason for hiding this comment

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

It is recommended to use Get.find centralized in one place

Copy link
Member

@dab246 dab246 left a comment

Choose a reason for hiding this comment

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

Quick review:

  • Objects should be immutable
  • Fill in properties in props
  • Should create instance of Get.find and use it. Avoid writing: `Get.find().function()
  • Should create separate function for events in call from onTap, onClick
  • Note convension code :
    • There are too many parameters of the function, each parameter should be 1 line.
    • Indentation should be 1 tab

Copy link
Contributor

@EvGen94 EvGen94 left a comment

Choose a reason for hiding this comment

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

§


part 'base_message_event.dart';

part 'base_message_state.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! Thanks for the work, now everything is done on сubits and I don't see the point in adding new blocks with events, it's better to keep everything on сubits IMHO

@ManhNTX
Copy link
Collaborator Author

ManhNTX commented Jan 27, 2023

§

Hi! Reason to change some cubit to bloc:

  1. Some case i want trigger many event in 1 action or i want make action concurrency (sample when change workspace i want to cancel action fetch A workspace and start B workspace).
  2. It make clearly, and i don't covert all cubit to bloc, just only abstract cubit.

@ManhNTX ManhNTX force-pushed the feature/refactor_code branch 2 times, most recently from 9c6fb44 to 1abcb50 Compare January 29, 2023 20:14
@ManhNTX ManhNTX force-pushed the feature/refactor_code branch from 1abcb50 to 47a445e Compare January 30, 2023 02:24
import 'package:twake/core/state/success.dart';

@immutable
abstract class AppState with EquatableMixin {
Copy link
Member

Choose a reason for hiding this comment

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

why we need this class?

this._messageRepository,
);

Either<ExceptionFailure, Stream<List<Message>>> execute({ String? companyId,
Copy link
Member

Choose a reason for hiding this comment

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

@@

import 'package:flutter/material.dart';
import 'package:twake/models/globals/globals.dart';

abstract class RepositoryHelper {
Copy link
Member

Choose a reason for hiding this comment

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

can you explain your idea?

Comment on lines +9 to +13
if (!Globals.instance.isNetworkConnected) {
onLocal?.call();
return;
}
onRemote?.call();
Copy link
Member

Choose a reason for hiding this comment

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

IMO, it is not generic enough. For example: when we need to first: fetch data from local, in parallel, fetch the data with network to update.


if (event.threadId == null) emit(MessagesLoadInProgress());

final result = _fetchMessageUseCase.execute(
Copy link
Member

Choose a reason for hiding this comment

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

IMO, we need an method to execute all the usecase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants