๐Ÿš€ Hive dApps Dev Update: Distriator Gets Smarter ๐Ÿง โšก๏ธ โ€” Frontend, Caching & Lightning Fast Sync!

(75)in#hive-139531โ€ข

Hey Hive Fam!

Welcome back, coding ninjas & blockchain bees! ๐Ÿ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป
It's time for another Hive Dev Logโ€”with plenty of nerdy upgrades and just enough memes to keep you giggling. Strap in!


๐Ÿ”Ž Whatโ€™s New in Distriator Frontend?

In my previous update, we turbocharged backend data sync.
Today, it's the frontend's turn!
No more loading every business every time โ€” just the fresh stuff, delivered FAST. ๐Ÿคฉ

reactjs data-sync


๐Ÿ—‚๏ธ Business Data Caching System

Whatโ€™s going on?

Say goodbye to slow, heavy API calls! Meet the new caching system for the businesses API.
Think: More speed. Less strain. MongoDB finally gets to chill. ๐Ÿง˜โ€โ™‚๏ธ


โš’๏ธ Changes Made

API Endpoint Shuffle
  • Old Endpoint: /business โ€” fetched all businesses, all the time (talk about TMI ๐Ÿ˜„)
  • New Hotness: /business/modified-after โ€” fetches only those that actually changed (so smart!)

The old version is still live, but todayโ€™s fun is all about the new, efficient one!


Business Model Patch

We got geeky:

  • Added: createdAt (when business was born)
  • Added: updatedAt (when business had a makeover)
  • Purpose: Helps us sync only whatโ€™s new or changed. Like, why call your mom if nothing happened? ๐Ÿ˜…

api end point image reference


๐Ÿง  Caching That Works Smarter, Not Harder
  • First-Time Use:

    • App calls /business/modified-after with the OG timestamp (1970-01-01T00:00:00.000Z) โ€” back to the dinosaurs! ๐Ÿฆ–
    • Saves encrypted businesses locally.
    • Grabs max updatedAt timestamp, notes it for next sync.

    Screenshot of code snippet to grab max date from list of businesses

  • Storage Keys:

    • cached_businesses: Encrypted business bonanza
    • last_modified_timestamp: ISO8601 timestamp
  • Next Calls:

    • Uses stored timestamp, fetches whatโ€™s NEW or UPDATED only
    • Merges with cache, filters isDeleted: true
    • Updates timestamp because, well, time only moves forward!

    Smart meme gif

  • Result:
    Faster loads, happier database, and yes โ€” MongoDB FINALLY takes a coffee break. โ˜•๏ธ


๐Ÿ” Data Safety Dance
  • Everything's locked up tight: Encrypted localStorage for businesses
  • Only timestamps sit in plain textโ€”nobody hacks what they canโ€™t read! ๐Ÿ˜Ž
  • Raw API payload is never decrypted locally.
  • Reminder: Thereโ€™s no hack-proof, but we make it tough for ordinary mortals.

๐Ÿค– New & Improved Functions

fetchBusinessesModifiedAfter()

fetchBusinessesModifiedAfter code

  • Fetches only what's needed, using ISO8601 date
  • Talks to server, grabs just fresh or updated business data

fetchBusinessesApi()

fetchBusinessesApi

  • Main caching logic!
  • Gives you cached data if nothing changed (like a chill librarian ๐Ÿ“š)
  • Used to fetch everything, now fetches intelligently

clearBusinessesCache()

  • Nukes all cached dataโ€”useful for tests or hitting big red reset
  • Resets timestamps to prehistory
  • Keeps devs a little saner

๐ŸŽจ UI Flare

Refresh Button

Refresh button

  • Starring on BusinessList (desktop + mobile)
  • Shows spinny loading (who doesnโ€™t love a good spinner!)
  • Disabled during heavy lifting

Context Upgrade

  • BusinessesContext gets a new superhero: forceRefreshBusinesses
  • Still plays nice with all the old components ๐Ÿงฉ

โญ Why This Rocks

  1. Less API Loading: Only gets what's changed, not the whole kitchen sink!
  2. Turbo Speed: Returning users zoom through business lists
  3. Offline Ninja: Works even if server's snoozing
  4. Self-Healing Data: Handles updates, merges, deletions, all behind the curtain
  5. Youโ€™re in Control: Smash refresh manually if you canโ€™t wait!

If no data

And if thereโ€™s nada โ€” response in 500ms!
Server down? No prob, cache to the rescue.
Now thatโ€™s a WOW feature.

isn't that just wow moment gif


๐Ÿฅ What's Next?

  • Backend: โœ”๏ธ Already done!
  • Frontend: โœ”๏ธ All juiced up!
  • Next up: Claim Cashback API gets some turbo tweaks!
    • Two pieces:
      1. See available cashback
      2. Claim it post-business review
  • Stay tuned โ€” next dev log will have the spicy details!

๐ŸŽ‰ The Hive Hype Never Stops ๐Ÿš‚

  • ๐Ÿ™Œ Keep shopping & keep claiming with Distriator
  • ๐Ÿ’ Big love, Hive family!
  • ๐Ÿ“ˆ Hive blockchain = ๐Ÿš€๐Ÿš€ to the moon, Mars & beyond!

Lots of love for hive meme

๐Ÿ”ฅ Until the next dev log โ€” Keep building, keep Hiving! ๐Ÿ’œ๐Ÿ


๐Ÿ“ Final Note


๐Ÿš€ My Contributions to โ™ฆ๏ธ Hive Ecosystem

ContributionToHiveEcosystem
Hive Witness NodeHive API Node3Speak Video Encoder Node Operator (highest number of nodes)3Speak Mobile App Developer
3Speak Podcast App Developer3Speak Shorts App Developer3Speak Support & Maintenance TeamDistriator Developer
CheckinWithXYZHive InboxHiFindHive Donate App
Contributed to HiveAuth Mobile AppEcency โ†” 3Speak IntegrationEcency โ†” InLeo IntegrationEcency โ†” Actifit Integration
Hive Stats AppVote for Witness AppHiveFlutterKitNew 3Speak App

๐Ÿ™Œ Support Back

โค๏ธ Appreciate my work? Consider supporting @threespeak & @sagarkothari88! โค๏ธ


inHiveDevsby
(75)
$5.58
||
Sort:
  • coldbeetrootsoup profile picture(75)

    Another Update? ๐Ÿ˜ง I see you posting new Updates for different projects every day. You have been very bussy Sagar ๐Ÿ˜

    $0.00
    • sagarkothari88 profile picture(75)

      Thank you @coldbeetrootsoup

      Comments like this and People like you keep me going

      Onwards & upwards

      onward together

      Stronger together

      $0.00
    • melinda010100 profile picture(78)

      All this and you still have time to leave comments on posts? You are awesome.

      $0.00
      • sagarkothari88 profile picture(75)

        Thank you @melinda010100 Motivating Shadow, Reflection, Bird hunters is one of my daily to-do.

        $0.00
        • melinda010100 profile picture(78)

          Your comments are definitely appreciated!! !LADY !INDEED !PIZZA

          $0.00
          • sagarkothari88 profile picture(75)

            your hard work

            • to motivate community members
            • to engage with community members
            • to distribute rewards
            • to host several contests

            never goes unnoticed

            Sashtang Pranam to you

            sashtang

            $0.00
      • pizzabot profile picture(59)

        PIZZA!

        $PIZZA slices delivered: @melinda010100(3/15) tipped @sagarkothari88

        Come get MOONed!
        $0.00