Files
bsky-social-app/src/storage
Eric Bailey a2019aceec Trending (Beta) (#7144)
* Add WIP UIs for trending topics and suggested starterpacks

* Disable SPs for now

* Improve explore treatment a bit, add some polish to cards

* Add tiny option in RightNav

* Add persisted option to hide trending from sidebar

* Add to settings, abstract state, not updating in tab

* Fix up hide/show toggle state, WITH broadcast hacK

* Clean up persisted code, add new setting

* Add new interstitial to Discover

* Exploration

* First hack at mute words

* Wire up interstitial and Explore page

* Align components

* Some skeleton UI

* Handle service config, enablement, load states, update lex contract

* Centralize mute word handling

* Stale time to 30m

* Cache enabled value for reloads, use real data for service config

* Remove broadcast hack

* Remove titleChild

* Gate settings too

* Update package, rm langs

* Add feature gate

* Only english during beta period

* Hook up real data

* Tweak config

* Straight passthrough links

* Hook up prod agent

* Fix no-show logic

* Up config query to 5 min

* Remove old file

* Remove comment

* Remove stray flex_1

* Make trending setting global

* Quick placeholder state

* Limit # in sidebar, tweak spacing

* Tweak gaps

* Handle hide/show of sidebar

* Simplify messages

* Remove interstitial

* Revert "Remove interstitial"

This reverts commit 1358ad47fd.

* Only show interstitial on mobile

* Fix gap

* Add explore page recommendations

* [topics] add topic screen (#7149)

* add topic screen

* decode

* fix search query

* decode

* add server route

* Fix potential bad destructure (undefined)

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Co-authored-by: Hailey <me@haileyok.com>
2024-12-17 19:45:39 -08:00
..
2024-09-05 12:31:24 -07:00
2024-09-05 12:31:24 -07:00
2024-12-17 19:45:39 -08:00

#/storage

Usage

Import the correctly scoped store from #/storage. Each instance of Storage (the base class, not to be used directly), has the following interface:

  • set([...scope, key], value)
  • get([...scope, key])
  • remove([...scope, key])
  • removeMany([...scope], [...keys])

For example, using our device store looks like this, since it's scoped to the device (the most base level scope):

import { device } from '#/storage';

device.set(['foobar'], true);
device.get(['foobar']);
device.remove(['foobar']);
device.removeMany([], ['foobar']);

TypeScript

Stores are strongly typed, and when setting a given value, it will need to conform to the schemas defined in #/storage/schema. When getting a value, it will be returned to you as the type defined in its schema.

Scoped Stores

Some stores are (or might be) scoped to an account or other identifier. In this case, storage instances are created with type-guards, like this:

type AccountSchema = {
  language: `${string}-${string}`;
};

type DID = `did:${string}`;

const account = new Storage<
  [DID],
  AccountSchema
>({
  id: 'account',
});

account.set(
  ['did:plc:abc', 'language'],
  'en-US',
);

const language = account.get([
  'did:plc:abc',
  'language',
]);

Here, if ['did:plc:abc'] is not supplied along with the key of language, the get will return undefined (and TS will yell at you).