chinchang / web-maker

A blazing fast & offline frontend playground
https://webmaker.app
MIT License
2.54k stars 314 forks source link

Out of sync with live version #556

Closed SantoshSrinivas79 closed 2 months ago

SantoshSrinivas79 commented 2 months ago

Meta info

After installing and building a release and self-hosting, below are few that seem to not work on:

I tried debugging a bit and looks like there is problem state management in the master branch. Pls advise.

CleanShot 2024-05-06 at 16 58 51

chinchang commented 2 months ago

Hi @SantoshSrinivas79 !

SantoshSrinivas79 commented 2 months ago

Hi @chinchang, Here you go sir. The only thing I did is update, src/firebaseInit.js with my details and did a gulp release. I am serving the app using nginx from the dist folder.

I added all logs in the video below. I enabled window.DEBUG by hardcoding to ensure logging. I tried a bit of debugging and see that calls to firestore are working but the data is not getting rendered in the UI.

https://github.com/chinchang/web-maker/assets/1036163/42f88ac2-ae2c-4cfc-8191-741c257835e5

On glancing through the code, I see that the UI elements are getting rendered from information in the state.

chinchang commented 2 months ago

The issue was related to the Firebase error you see in your video about not being able to update the user document. Actual Web maker creates a user document for every one behind the scenes. Since you have your own DB (without the cloud functions), you didn't have the user document for your user. Now the specific reason why the items were not fetched was because the fetching was somehow tied to reading the user document. It was not required really and I have fixed it now. If you get the latest master and run that, it should be working!

Let me know if it doesn't.

SantoshSrinivas79 commented 2 months ago

Thanks a ton. Works great @chinchang !

Just a tiny point ... I think the user doc fix can be made for this section too: CleanShot 2024-05-07 at 17 17 55

My saved items are showing up correctly! Thanks a ton! :)

One small help, can you please document the exact firestore privacy rules? I made them too generic in my install :)

chinchang commented 2 months ago

Hey @SantoshSrinivas79 I think for a private self-hosted app, these rules should be enough:

service cloud.firestore {
  match /databases/{database}/documents {

    function isAuthenticatedCreation() {
        return request.auth.uid == request.resource.data.createdBy;
    }
    function isAuthenticatedUpdation() {
        return request.auth.uid == resource.data.createdBy;
    }

    match /items/{itemId} {
      allow create: if isAuthenticatedCreation();
      allow update: if isAuthenticatedUpdation();
      allow read: if request.auth.uid == resource.data.createdBy;
    }

     match /{document=**} {
      allow read, write: if false;
    }
  }
}
SantoshSrinivas79 commented 2 months ago

@chinchang Thank you sir