DanielQuick / Flutter-Sprints-Idea-Tracker

3 stars 1 forks source link

Sprint Service Enhancement #30

Closed DanielQuick closed 3 years ago

DanielQuick commented 3 years ago
taracell commented 3 years ago

Join Sprint and Leave Sprint can be accomplished by adding or subtracting members within the sprint object using Enum Update.addMember, Update.deleteMember when you call the Sprint object, it returns a property labeled members which is a list of strings of members stored as an array in Firebase Firestore.

taracell commented 3 years ago

Examples/use cases: Join/Leave call parameters are Sprint, UpdateSprint enum, String Join button:

_sprint = await _sprintService.update(_sprint, UpdateSprint.addMember, 'member4');

Leave button:

 _sprint = await _sprintService.update(_sprint, UpdateSprint.deleteMember, 'member4');

Please remember that the sprint post are stored as List\<SprintPost> within the Sprint object Create team lead post call parameters are Sprint, SprintPost where a SprintPost object is defined like this:

    SprintPost _post0 = new SprintPost(
        id: \<Define your own and follow it\>
        title: 'Sprint Post 0',
        content: 'Content 0',
        createdAt: DateTime.now().millisecondsSinceEpoch);

Create Post:

_sprint = await _sprintService.updatePost(_sprint, UpdatePost.create,  _post0);

The number 1 below is the index of the list that the sprint post is in. Once you delete a post the next post if any moves up into that space.
Delete Post:

 _sprint = await _sprintService.updatePost(_sprint, UpdatePost.delete, _sprint.posts[1]);

***Since these posts are members of the Sprint Object as a List to update the post get the list index and remove then create a new post from that SprintPost...Use delete then create for update.