Closed DmitrySharabin closed 4 years ago
I think #15 is a related problem.
After looking at this a bit more, it seems to me that the backend should be initializing one, and only one, firebase app per projectId. There has to be a different one for each projectId because the projectId is part of the app configuration. But there's no benefit I can see to having more than one per projectId because there's nothing we can beneficially vary between two such apps.
I assume that by far the common case would be to have only one projectId for all apps on the page; in this case it would seem natural to just initialize the default firebase app. If there is more than one projectId on the page, you could initialize each app using the projectId as the app name. Or maybe this should be what you always do, since then you don't have to decide which case you are in.
Thank you for reporting this bug and your suggestion. It absolutely makes sense, and I implemented it the way you proposed.
Will you please check whether now it works the way you expect? It's still available only in the dev version. If anything goes wrong, we can reopen the issue.
I put some comments on certain commits; I'm not sure if you get notified about those.
I am notified, don't worry. Thank you.
Am I right that there will still be a need to login twice on a page where 2 apps have the same project ID? If so I will wait to test until that is fixed.
Nope, you don’t need to login twice.
The only reason you will have to do that is when you will use apps with different projectId
s on the same page.
Reported by @karger
Using the current deployed version, I get a weird bug where if I change the storage location of a firebase mavo dynamically I get errors saying there is already an app defined with that name.
Actually, the bug is present in the development version as well.
It appears that when I change the mv-storage of an app, mavo invokes an
updateBackend
function. This leads to an invocation of newBackend(url,o)
from mavo which invokes the firebase constructor. And your constructor callsfirebase.initializeApp()
with the config which includes the name of the mavo app—which is an error if that same mavo app was previously initialized.I'm not sure if mavo should be differentiating an instance of update-backend from create-backend but right now it appears they are combined so your constructor needs to figure out which case it is in.