dsc-x / omg-frames

https://myframe.dscomg.com
MIT License
6 stars 12 forks source link

Performance Issue: Unnecessary GET request for deleting frames #9

Closed arnabsen1729 closed 3 years ago

arnabsen1729 commented 3 years ago

Description

https://github.com/dsc-x/omg-frames/blob/332ec82c7905799a4986ac81c20772e08fd35d6c/js/loginsignup.js#L162-L181

When a user heads over to gallery.html and then deletes an image, two requests happen one DELETE and another GET (line number 169) . Now the GET request is very time-consuming, so we should try to make fewer GET requests.

Solution

When the user first loads the gallery.html, we make one GET request and store the data we get in an array. Each element of an array represent one frame. For deletion, we can simply make the DELETE request and remove the corresponding frame from the array, and also toggle the display of that frame. This will make sure that there is one GET request in that user session.

rajinderpalsingh2001 commented 3 years ago

Previously:

gallery.html loads ---> getframes() called with GET request for Getting Frames if (user deletes frame ){ deleteframe() called getframes() again called for fetching again frames }

Now:

gallery.html loads ---> getframes() called with GET request for Getting Frames --->all frames stored in array ---> displayarrayofframes() called for displaying fetched array

if (user deletes frame ){ deleteframe() called delete that frame from array displayarrayofframes() called }