darcydriscoll / chat-room

A small chat room made w/ Vue, Tailwind, MySQL, and PHP.
MIT License
0 stars 0 forks source link

Connect client-side with the server-side #6

Closed darcydriscoll closed 2 years ago

darcydriscoll commented 3 years ago

Requirements

  1. Client asks the server if we're already signed in
  2. If the answer is 'true', then continue to chat room page
  3. Else, wait for user to submit their desired nickname
  4. Client asks the server if we can sign in with this nickname
  5. If the answer is 'true', play tick animation, the continue to chat room page
  6. Else, if the answer is 'false', and the error is 'nickname invalid', tell the user that the nickname is invalid (go to 3)
  7. Else, if the answer is 'false', and the nickname is already taken, tell the user that the nickname is already taken (go to 3)
  8. Else, if the answer is 'false', and the server doesn't know what happened, tell the user that there's been an error and to try again (go to 3)
  9. Else, if we don't get an answer, tell the user that there's been an error and to try again (go to 3)

Notes

Remaining criteria as of 14/02/2022

darcydriscoll commented 2 years ago

Having trouble with Apache server configuration:

Maybe I could play around with the rewriting conditions and see what I find.

darcydriscoll commented 2 years ago

Having trouble with Apache server configuration:

  • When I set RewriteBase to "/", Apache doesn't start. Why?

  • When I don't include RewriteBase, Apache starts. But pages don't load correctly. By the errors I'm getting, it seems that whenever the client tries to get the relevant JS files from the server, the server returns a file that starts with '<' instead. This is probably a .html file, and likely 'index.html'. Are the rewriting conditions too broad?

Maybe I could play around with the rewriting conditions and see what I find.

Causes for both of these issues:

darcydriscoll commented 2 years ago

Doesn't look like any other server configuration needs to be done.

Currently, we push the user to /index.html when they get a URL that doesn't physically exist (e.g. /chatroom, or a random string of characters). But: the URI that the user sees stays the same, and vue-router uses that URI, not the page the user is pushed to! So, as long as we get things right logically, we're good.

This does mean we have to get things right logically though. So I'll add that to the to-do list.

darcydriscoll commented 2 years ago

Added a fade-in transition for the sign-in page. I won't be adding any more in this story, because I don't know how I want the app to fade between the sign-in page and the chat room page yet.

darcydriscoll commented 2 years ago

I extended the session lifetime to 72 hours. This lets users keep their nicknames around for longer without allowing trolls to hog nicknames for too long.

darcydriscoll commented 2 years ago

Working on simple PHP error handling and propagation to client. Some things to look into:

darcydriscoll commented 2 years ago

Whoops!

darcydriscoll commented 2 years ago

I've implemented rudimentary error handling such that most errors are propagated down to the client. Some things to refactor:

darcydriscoll commented 2 years ago

Working on standardising error codes. I've got it working on the server-side, now I'm working on the client-side.

It's more complex than I thought it would be. I guess I've never done this combination of array manipulation and file handling before. They're not areas that I'm especially competent in.

darcydriscoll commented 2 years ago

I've put some work into client-side error codes. Again, harder than I thought.

I need a way to prevent the SignIn component from doing anything before we've fetched the error codes and processed them. We could use .then and a data property to record when everything is loaded? Then, use that data property on the template to turn on/animate/brighten the sign in component when it hits true.

Or -- can we make use of await in Vue lifecycle methods? Anything else in Vue -- async components? <Suspense>?

darcydriscoll commented 2 years ago

Done! Added attributions as well.