Update metadata comments, dev mode
This commit is contained in:
@@ -93,6 +93,9 @@ export type ThreadItem =
|
||||
onPress: () => void
|
||||
}
|
||||
| {
|
||||
/*
|
||||
* Read more replies, downwards in the thread.
|
||||
*/
|
||||
type: 'readMore'
|
||||
key: string
|
||||
depth: number
|
||||
@@ -101,6 +104,9 @@ export type ThreadItem =
|
||||
skippedIndentIndices: Set<number>
|
||||
}
|
||||
| {
|
||||
/*
|
||||
* Read more parents, upwards in the thread.
|
||||
*/
|
||||
type: 'readMoreUp'
|
||||
key: string
|
||||
href: string
|
||||
@@ -110,12 +116,17 @@ export type ThreadItem =
|
||||
key: string
|
||||
item: 'anchor' | 'reply' | 'replyComposer'
|
||||
}
|
||||
| {
|
||||
type: 'bookend'
|
||||
key: string
|
||||
direction: 'up' | 'down'
|
||||
}
|
||||
|
||||
/**
|
||||
* Metadata collected while traversing the raw data from the thread response.
|
||||
* Some values here can be computed immediately, while others need to be
|
||||
* computed during a second pass over the thread after we know things like
|
||||
* totaly number of replies, the reply index, etc.
|
||||
*
|
||||
* The idea here is that these values should be objectively true in all cases,
|
||||
* such that we can use them later — either individually on in composite — to
|
||||
* drive rendering behaviors.
|
||||
*/
|
||||
export type TraversalMetadata = {
|
||||
/**
|
||||
* The depth of the post in the reply tree, where 0 is the root post. This is
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
type ThreadItem,
|
||||
type TraversalMetadata,
|
||||
} from '#/state/queries/usePostThread/types'
|
||||
import {isDevMode} from '#/storage/hooks/dev-mode'
|
||||
import * as bsky from '#/types/bsky'
|
||||
|
||||
export function getThreadgateRecord(
|
||||
@@ -111,7 +112,7 @@ export function storeTraversalMetadata(
|
||||
) {
|
||||
metadatas.set(metadata.postData.uri, metadata)
|
||||
|
||||
if (__DEV__) {
|
||||
if (isDevMode()) {
|
||||
// @ts-ignore dev only for debugging
|
||||
metadatas.set(metadata.postData.text, metadata)
|
||||
// @ts-ignore
|
||||
|
||||
@@ -5,3 +5,17 @@ export function useDevMode() {
|
||||
|
||||
return [devMode, setDevMode] as const
|
||||
}
|
||||
|
||||
let cachedIsDevMode: boolean | undefined
|
||||
/**
|
||||
* Does not update when toggling dev mode on or off. This util simply retrieves
|
||||
* the value and caches in memory indefinitely. So after an update, you'll need
|
||||
* to reload the app so it can pull a fresh value from storage.
|
||||
*/
|
||||
export function isDevMode() {
|
||||
if (__DEV__) return true
|
||||
if (cachedIsDevMode === undefined) {
|
||||
cachedIsDevMode = device.get(['devMode']) ?? false
|
||||
}
|
||||
return cachedIsDevMode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user