Update metadata comments, dev mode
This commit is contained in:
@@ -93,6 +93,9 @@ export type ThreadItem =
|
|||||||
onPress: () => void
|
onPress: () => void
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
/*
|
||||||
|
* Read more replies, downwards in the thread.
|
||||||
|
*/
|
||||||
type: 'readMore'
|
type: 'readMore'
|
||||||
key: string
|
key: string
|
||||||
depth: number
|
depth: number
|
||||||
@@ -101,6 +104,9 @@ export type ThreadItem =
|
|||||||
skippedIndentIndices: Set<number>
|
skippedIndentIndices: Set<number>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
/*
|
||||||
|
* Read more parents, upwards in the thread.
|
||||||
|
*/
|
||||||
type: 'readMoreUp'
|
type: 'readMoreUp'
|
||||||
key: string
|
key: string
|
||||||
href: string
|
href: string
|
||||||
@@ -110,12 +116,17 @@ export type ThreadItem =
|
|||||||
key: string
|
key: string
|
||||||
item: 'anchor' | 'reply' | 'replyComposer'
|
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 = {
|
export type TraversalMetadata = {
|
||||||
/**
|
/**
|
||||||
* The depth of the post in the reply tree, where 0 is the root post. This is
|
* 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 ThreadItem,
|
||||||
type TraversalMetadata,
|
type TraversalMetadata,
|
||||||
} from '#/state/queries/usePostThread/types'
|
} from '#/state/queries/usePostThread/types'
|
||||||
|
import {isDevMode} from '#/storage/hooks/dev-mode'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function getThreadgateRecord(
|
export function getThreadgateRecord(
|
||||||
@@ -111,7 +112,7 @@ export function storeTraversalMetadata(
|
|||||||
) {
|
) {
|
||||||
metadatas.set(metadata.postData.uri, metadata)
|
metadatas.set(metadata.postData.uri, metadata)
|
||||||
|
|
||||||
if (__DEV__) {
|
if (isDevMode()) {
|
||||||
// @ts-ignore dev only for debugging
|
// @ts-ignore dev only for debugging
|
||||||
metadatas.set(metadata.postData.text, metadata)
|
metadatas.set(metadata.postData.text, metadata)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -5,3 +5,17 @@ export function useDevMode() {
|
|||||||
|
|
||||||
return [devMode, setDevMode] as const
|
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