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

delete label and delete project functionality added #35

Closed
wants to merge 3 commits into from

Conversation

gourav1486
Copy link

I have added delete label and delete project functionality at any time from drawer by clicking delete icon . on pressing delete icon that label or that project can be deleted

@@ -47,7 +47,7 @@ class LabelDB {
return labels;
}

Future deleteLabel(int labelId) async {
Future deleteLabel(int? labelId) async {

Choose a reason for hiding this comment

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

Is this change for deleting a label with labelId null? Can this happen?

Copy link
Author

Choose a reason for hiding this comment

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

yes

Copy link
Author

Choose a reason for hiding this comment

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

int? can take null value also

Copy link
Owner

Choose a reason for hiding this comment

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

Why would int will be null for deleting the project?

Copy link
Author

Choose a reason for hiding this comment

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

sir when we are building list of labels it may give us value null, and whenever i was using int it was showing me error that int cant be assigned to type int?

Copy link
Owner

Choose a reason for hiding this comment

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

First of all. You don't need to call me sir.
You can mark deleteLabel int as non-nullable and before calling this method check if the argument passed in deleteLabel is not null. Something like

if (lable.id! = null) {
  labelDb.deleteLabel(label.id);
}

Copy link
Author

Choose a reason for hiding this comment

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

ok
i will go through it.

Copy link
Author

Choose a reason for hiding this comment

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

it dose not worked for me, when I tried to remove int? it was showing error: The argument type 'int?' can't be assigned to the parameter type 'int'. How can I deal with it

Copy link
Owner

@burhanrashid52 burhanrashid52 left a comment

Choose a reason for hiding this comment

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

Since deleting a label is a cascade operation which will also delete the project associated with the project and label. To have a better UX we can show a confirmation dialog before deleting it. The dialog message could say "Are you sure want to delete this label/project? This will also delete the project associated with this label/project ?"

@@ -47,7 +47,7 @@ class LabelDB {
return labels;
}

Future deleteLabel(int labelId) async {
Future deleteLabel(int? labelId) async {
Copy link
Owner

Choose a reason for hiding this comment

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

Why would int will be null for deleting the project?

),
),
);
}

del(int? id) async {
Copy link
Owner

Choose a reason for hiding this comment

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

Currently, the app uses the BLoC pattern which responsible for this type of operation. I would suggest this to move to LableBloc and so whenever the label is deleted update the getLables stream.

Copy link
Author

Choose a reason for hiding this comment

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

can you please guide sir

Copy link
Owner

Choose a reason for hiding this comment

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

@nightscape would you like to help here? You've been added as reviewer here.

Choose a reason for hiding this comment

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

@burhanrashid52 though I would love to get my hands dirty with WhatTodo, I'm just in the process of converting a few libraries to Scala 3, so my Open Source time is already booked out...

Copy link
Owner

Choose a reason for hiding this comment

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

@nigthscape okay no problem. @gourav1486 First you need to move this delete method in their respective bloc. i.e LabelBloc and ProjectBloc and call delete method on the bloc. And then when it successfully deletes it, then call refresh() also you need to revert ProjectRow and LabelsRow to StatelessWidget. Can you please add a test for this deletion? You can refer to tests in integration_tests.

Copy link
Author

Choose a reason for hiding this comment

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

done but I was unable to make labelRow stateless and its my first open source contribution so I have no idea about adding test about deletion can you please guide me?

Copy link
Owner

Choose a reason for hiding this comment

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

You check the existing test code in app that might help to get started with.

@@ -69,39 +70,62 @@ class LabelExpansionTileWidget extends StatelessWidget {
}
}

class LabelRow extends StatelessWidget {
class LabelRow extends StatefulWidget {
Copy link
Owner

Choose a reason for hiding this comment

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

We can move the state to LabelBloc and keep the LabelRow StatelessWidget

trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {
projectDb.deleteProject(project.id);
Copy link
Owner

Choose a reason for hiding this comment

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

We try to not expose DB directly on UI instead do this operation in the bloc.

Copy link
Author

Choose a reason for hiding this comment

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

AlertDialog box added please review for any changes

@gourav1486
Copy link
Author

Since deleting a label is a cascade operation which will also delete the project associated with the project and label. To have a better UX we can show a confirmation dialog before deleting it. The dialog message could say "Are you sure want to delete this label/project? This will also delete the project associated with this label/project ?"

Added the change

@burhanrashid52
Copy link
Owner

@gourav1486 Can you please fix the conflicst and add a test ?

@burhanrashid52
Copy link
Owner

@gourav1486 Do you have any updates on this ?

@burhanrashid52
Copy link
Owner

Closing due to no activity

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.

3 participants