328aa2be94
* Add blocking announcement dialog feature * WIP custom dialog * Rework dialog and add native FocusScope * Lock scroll on web, fix backdrop * Add web FocusScope * Create custom Outlet for these announcements * Clean up FocusScope native impl * Comments * Some styling fixes * Handle screen reader specifically * Clean up state, remove Portal edits * Reorg, rename * Add syncing, tests * Revert dialog updates * Revert formatting * Delete unused file * Format * Add FullWindowOverlay * remove mmkv storage in debug btn * Add debug code * fix taps passing through on iOS * Reorg * Reorg, rename everything * Complete policy update after signup * Add logger * Move context around, unmount portals on native * Move a11y prop into FocusScope * Remove useMemo * Update dates * Move debug to dev settings * Unmount web portals until policy update completed * UPdate dates --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
#/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).