Skip to content

Commit

Permalink
Still accept title instead of label for now, mark as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmischka committed Mar 10, 2023
1 parent 3e3b30f commit 96a618b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/classes/TransactionLoadingState.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { LoadingOptions, LoadingState } from '../internalRpcSchema'
import {
BackwardCompatibleLoadingOptions,
BackwardCompatibleLoadingState,
} from '../internalRpcSchema'
import Logger from './Logger'

export interface TransactionLoadingStateConfig {
logger: Logger
send: (loadingState: LoadingState) => Promise<void>
send: (loadingState: BackwardCompatibleLoadingState) => Promise<void>
}

export default class TransactionLoadingState {
#logger: Logger
#sender: TransactionLoadingStateConfig['send']
#state: LoadingState | undefined
#state: BackwardCompatibleLoadingState | undefined
#sendTimeout: NodeJS.Timeout | null = null
#sendTimeoutMs = 100

Expand Down Expand Up @@ -49,7 +52,7 @@ export default class TransactionLoadingState {
* await ctx.loading.start("Label only shorthand");
*```
*/
async start(options?: string | LoadingOptions) {
async start(options?: string | BackwardCompatibleLoadingOptions) {
if (typeof options === 'string') {
options = { label: options }
} else if (options === undefined) {
Expand Down Expand Up @@ -81,7 +84,7 @@ export default class TransactionLoadingState {
* });
*```
*/
async update(options?: string | LoadingOptions) {
async update(options?: string | BackwardCompatibleLoadingOptions) {
if (!this.#state) {
this.#logger.warn('Please call `loading.start` before `loading.update`')
return this.start(options)
Expand Down
5 changes: 4 additions & 1 deletion src/components/displayGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ type PublicProps<Row = any> = Omit<
T_IO_PROPS<'DISPLAY_GRID'>,
'data' | 'totalRecords' | 'isAsync'
> & {
renderItem: (row: Row) => GridItem
renderItem: (row: Row) => GridItem & {
/** @deprecated Please use `label` instead. */
title?: string | null
}
} & (
| {
data: Row[]
Expand Down
6 changes: 5 additions & 1 deletion src/internalRpcSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const LOADING_STATE = z.object({

const BACKWARD_COMPATIBLE_LOADING_STATE = LOADING_STATE.merge(
z.object({
// @deprecated in favor of `label` (for real this time)
/** @deprecated in favor of `label` (for real this time) */
title: z.string().optional(),
})
)
Expand All @@ -65,6 +65,10 @@ const SDK_ALERT = z.object({
export type SdkAlert = z.infer<typeof SDK_ALERT>

export type LoadingOptions = z.input<typeof LOADING_OPTIONS>
export type BackwardCompatibleLoadingOptions = LoadingOptions & {
/** @deprecated Please use `label` instead. */
title?: string
}
export type LoadingState = z.input<typeof LOADING_STATE>
export type BackwardCompatibleLoadingState = z.input<
typeof BACKWARD_COMPATIBLE_LOADING_STATE
Expand Down

0 comments on commit 96a618b

Please sign in to comment.