question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unified media handling

See original GitHub issue

In #459 I discussed some future steps we could take to further simplify media URL logic. This issue will be used to track those changes. Depending on the size, and coherent overlap of the work described here, I may submit a single PR, or break it into smaller chunks.

Tasks

  • Generate media URLs client-side: there’s little remaining barrier to moving media URL parameterization to the client. Besides reducing unnecessary scope of the server’s responsibilities, it will also unblock some of the other changes discussed in the first PR.

  • Offline-capable requests for media: currently these requests are handled by replacing src attributes with data-offline-src, with an additional step to look those up and initiate media loading each time a form/instance is loaded, when a form is reset, when repeat instances are added, and so on. This distinction can be eliminated, instead handling those requests in fetch events within the Service Worker. We may also be able to handle caching at that level rather than in IndexedDB, but I’ll likely split that off as a separate work item and defer it for another future follow-up.

  • Consistent handling of media URL resolution and requests: there are several different ways URLs are resolved, depending on their type/role in the form: binary defaults, media in labels, external secondary instances, last-saved, instance attachments. I plan to unify these so that there is one consistent way that all media URLs are resolved and requested/fulfilled.

It may be tempting to combine these last two tasks, as a Service Worker is capable of handling both and it would enable even further simplification. Unfortunately, Service Workers cannot run in some browsers’ private/incognito modes. While this is already a restriction of offline-capable mode, it’s not a reasonable limitation for online-only, edit or preview modes. In any case, consistent handling of URL resolution can be shared, and hopefully the offline portion will just be a small wrapper around that specific to the pertinent Service Worker APIs.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
lognaturelcommented, Oct 7, 2022

there is a line about that in the documentation mentioned under each GET endpoint

Oh! “The GET version of this endpoint is only meant to test the Enketo Smart Paper API in the browser. It does not launch new surveys and is therefore not of use for integrating with Enketo.” Now that you mention it I think you and I talked about this a thousand years ago and I’d totally forgotten and also apparently have forgotten how to read. Thank you! In a parallel universe, the decision could have been made to always use GET for requests that implicitly result in a transformed form being cached. We’re not in that world so can’t change it for the public API but seems reasonable to change it for the private API being discussed here.

1reaction
MartijnRcommented, Oct 7, 2022

Each endpoint has GET and POST variants with GET providing a subset of what POST does. I can’t think of any reason to have both.

I remember this one! 😃 The GET requests are only for developers to make a little easier to test (there is a line about that in the documentation mentioned under each GET endpoint). I believe I stole that idea from somewhere else. Stripe maybe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Reasons to Have a Unified Social Media Management ...
Here are six reasons taking a unified approach to social media management is better for business. Present a Consistent Brand Message. It doesn't...
Read more >
Unified
Unified is the most comprehensive technology and a full social media services provider company in the social advertising ecosystem.
Read more >
A Complete Guide To Unified Marketing Measurement
Unified marketing measurement combines data and insights from different ... However, with many marketers managing multiple campaigns across multiple media ...
Read more >
Unified Media Marketing Group
Unified Media Marketing Group is a full service digital marketing and advertising agency that specializes in website designs, website optimization and social ...
Read more >
Unified - LinkedIn
Unified is a leading provider of social advertising services and solutions ... social advertising, social media, and marketing platform ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found