Skip to content
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

Upgrade to Webnative 0.35 #89

Merged
merged 22 commits into from
Jan 5, 2023
Merged

Upgrade to Webnative 0.35 #89

merged 22 commits into from
Jan 5, 2023

Conversation

icidasset
Copy link
Contributor

@icidasset icidasset commented Nov 15, 2022

Upgrade to to Webnative v0.35.

Changes:

  • webnative.app() has been replaced by webnative.program(). Which is now the sole entry point of webnative (no more initialise or permissionedApp either). The reason for the rename is to avoid confusion with Webnative apps, the ones you create via the CLI or dashboard.
  • authed WAT session variable has been replaced by session. A Webnative program will only give you a session if you're authenticated. I didn't want two variables representing roughly the same state so I removed authed
  • You can only add Uint8Arrays to the filesystem. That means that strings, files and blobs all have to be converted to Uint8Arrays first. I added one util function for that and strings are converted with TextEncoder/TextDecoder (or use the uint8arrays library).
  • I replaced the base64 data URIs in the gallery with object urls pointing to Blobs for performance. I assume that's why the file size was set to max 5MB? I increased it to 20 since it's much faster now.
  • I created a program store because this is the main interaction point to do something with your program. As opposed to using the webnative global. For example, before you'd call webnative.auth.isUsernameValid(), now you'd use program.auth.isUsernameValid(). Reasoning here is that global state has been removed from webnative, so all state lives in your created Program. I'm not entirely sure creating a store was the right approach here, since I'm not familiar with Svelte. Let me know if there's a better way to do this.
  • I made some adjustments to the type checking code in the gallery. Still not ideal, but safer.

Let me know if anything else needs explaining or if you have ideas to further improve any of the API.

Remaining issues:

  • After linking another device, it still shows the non-authenticated view on the consumer. Refreshing the page fixes it, but it takes a few seconds.
  • Linking does not always work? Webnative issue? Needs more testing.

@vercel
Copy link

vercel bot commented Nov 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
webnative-app-template ✅ Ready (Inspect) Visit Preview Jan 5, 2023 at 6:03PM (UTC)
webnative-template ✅ Ready (Inspect) Visit Preview Jan 5, 2023 at 6:03PM (UTC)

src/lib/auth/account.ts Outdated Show resolved Hide resolved
@jeffgca
Copy link
Contributor

jeffgca commented Nov 15, 2022

  • webnative.app() has been replaced by webnative.program()

Why is this necessary? Is it just because the signature of the method has changed, or is there a semantic reason why "program" is better than "app". TBH I think "app" is more generically understandable by developers.

@icidasset
Copy link
Contributor Author

  • webnative.app() has been replaced by webnative.program()

Why is this necessary? Is it just because the signature of the method has changed, or is there a semantic reason why "program" is better than "app". TBH I think "app" is more generically understandable by developers.

That came out of discussion with Boris who found the usage of app in this context confusing (correct me if I'm wrong Boris). I more or less agree. We have the app platform code as well in webnative to create Fission apps. I think we want to look at app cloning too in the future (at least we discussed that in the past). Meaning, we could have a tighter integration with apps. So to avoid confusion between the two concepts I opted for program. This also fits better technically since you can create multiple programs that represent the same app.

@bgins bgins mentioned this pull request Nov 15, 2022
6 tasks
@bgins
Copy link
Member

bgins commented Nov 16, 2022

After linking another device, it still shows the non-authenticated view on the consumer. Refreshing the page fixes it, but it takes a few seconds.

I think the issue might be in loadAccount:

https://github.com/webnative-examples/webnative-app-template/blob/80a3b051be3f4c70c94c6fc9f97141d6b90e4780/src/lib/auth/account.ts#L79

Should this be updated with the session instead of authed?

@icidasset
Copy link
Contributor Author

Should this be updated with the session instead of authed?

That did the trick, thanks! Was expecting a type error for this one.

@cloudflare-pages
Copy link

cloudflare-pages bot commented Nov 16, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8eeb9e2
Status: ✅  Deploy successful!
Preview URL: https://5a254e95.webnative-template.pages.dev
Branch Preview URL: https://icidasset-webnative-0-35.webnative-template.pages.dev

View logs

src/lib/init.ts Outdated Show resolved Hide resolved
src/lib/auth/linking.ts Outdated Show resolved Hide resolved
@avivash
Copy link
Member

avivash commented Nov 21, 2022

@avivash @bgins I figured out what the linking issue is, the linking producer is sometimes created multiple times. Not sure why it happens though, something something subscription to session store?
Screenshot 2022-11-21 at 12 28 27
It happens whenever I am redirect to the "delegate-account" page (eg. by clicking connect-device button) If I'm already on that page and refresh, it works as intended.
Also happens on main branch, see console log at https://webnative-template.fission.app/

ahh interesting! I'll try to recreate/debug it 👀

So it seems the page is double mounted exclusively when it is the slot of the SidebarNav component. Not quite sure why yet, but it's a starting point 🤔

@avivash
Copy link
Member

avivash commented Nov 21, 2022

@avivash @bgins I figured out what the linking issue is, the linking producer is sometimes created multiple times. Not sure why it happens though, something something subscription to session store?
Screenshot 2022-11-21 at 12 28 27
It happens whenever I am redirect to the "delegate-account" page (eg. by clicking connect-device button) If I'm already on that page and refresh, it works as intended.
Also happens on main branch, see console log at https://webnative-template.fission.app/

ahh interesting! I'll try to recreate/debug it 👀

So it seems the page is double mounted exclusively when it is the slot of the SidebarNav component. Not quite sure why yet, but it's a starting point 🤔

@icidasset i've got a fix 👍🏼, will push it shortly

@avivash
Copy link
Member

avivash commented Nov 21, 2022

Issue I noticed: sometimes when you click on "photo gallery demo" in the menu, the app reloads entirely. Have you seen that @avivash @bgins ?

I'd never seen this before just now. It must been tied to a recent update. I'll take a look 👀 (though i'm having a hard time recreating it)

@avivash
Copy link
Member

avivash commented Nov 21, 2022

Issue I noticed: sometimes when you click on "photo gallery demo" in the menu, the app reloads entirely. Have you seen that @avivash @bgins ?

I'd never seen this before just now. It must been tied to a recent update. I'll take a look 👀 (though i'm having a hard time recreating it)

Okay, I think my fix for the delegate route re-mounting may have fixed this too because I can't recreate it anymore. I'll keep an eye on it though 👍🏼

@icidasset
Copy link
Contributor Author

Yup, seems to be all fixed! 🎉

@jessmartin
Copy link
Contributor

Waiting on the official 0.35 release!

@icidasset icidasset merged commit b0b9a20 into main Jan 5, 2023
@icidasset icidasset deleted the icidasset/webnative-0.35 branch January 5, 2023 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants