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

save button draft #30

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

save button draft #30

wants to merge 4 commits into from

Conversation

nolantuite
Copy link
Collaborator

Description: …

Tests Performed: …

Trello Card Link:

Copy link
Collaborator

@baylee-rl baylee-rl left a comment

Choose a reason for hiding this comment

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

this PR is unblocked now that auth is merged! you should be able to merge with develop and have the save button make the api request

ctx.status = 404;
return;
}
const user = null; //This is dependent on Auth to determine the author
Copy link
Collaborator

Choose a reason for hiding this comment

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

update this to use auth now that its merged

@@ -25,7 +26,7 @@ router.get('/:postID', async (ctx, next) => {
router.post('/', async (ctx, next) => {
const post = new Post();
post.id = new mongodb.ObjectId();
post.author = null; //This is dependent on Auth to determine the author
post.author = ctx.state.user.id;
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's change this to store the username - you can grab it by finding the user model first via id then grabbing the username from the user model. you'll also need to change (in the post model file) the author field to be a string instead of a user model

return;
}
const user = ctx.state.user.id;
user.savedPosts.push(post.id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ctx.state.user.id is just their id, so you'll have to use findOneBy with this id to grab the model first

@@ -47,7 +47,9 @@ class PostSongDetails extends StatelessWidget {
PostActionButton(
icon: Icons.bookmark_border,
text: "Save",
onPressed: () {},
onPressed: () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be filled in now - ahmed added the structure for making requests like this. essentially u can do this in steps:

  1. add a method to the PostRepository class called savePost - you can model it after the existing ones to make the post request to the route you added
  2. add a corresponding savePost method to the PostController class
  3. use the post controller in your post_action_button.dart file (in onPressed) to call savePost (example here)

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.

2 participants