-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
backend/src/routes/post.ts
Outdated
ctx.status = 404; | ||
return; | ||
} | ||
const user = null; //This is dependent on Auth to determine the author |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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: () { |
There was a problem hiding this comment.
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:
- 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
- add a corresponding savePost method to the PostController class
- use the post controller in your post_action_button.dart file (in onPressed) to call savePost (example here)
Description: …
Tests Performed: …
Trello Card Link: …