mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 03:17:02 -04:00
ReviewDB: Add Review Modal & Pagination (#1174)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
6300198a54
commit
3e3d05fc26
21 changed files with 803 additions and 394 deletions
|
@ -67,6 +67,7 @@ interface AwaiterOpts<T> {
|
|||
fallbackValue: T;
|
||||
deps?: unknown[];
|
||||
onError?(e: any): void;
|
||||
onSuccess?(value: T): void;
|
||||
}
|
||||
/**
|
||||
* Await a promise
|
||||
|
@ -94,8 +95,16 @@ export function useAwaiter<T>(factory: () => Promise<T>, providedOpts?: AwaiterO
|
|||
if (!state.pending) setState({ ...state, pending: true });
|
||||
|
||||
factory()
|
||||
.then(value => isAlive && setState({ value, error: null, pending: false }))
|
||||
.catch(error => isAlive && (setState({ value: null, error, pending: false }), opts.onError?.(error)));
|
||||
.then(value => {
|
||||
if (!isAlive) return;
|
||||
setState({ value, error: null, pending: false });
|
||||
opts.onSuccess?.(value);
|
||||
})
|
||||
.catch(error => {
|
||||
if (!isAlive) return;
|
||||
setState({ value: null, error, pending: false });
|
||||
opts.onError?.(error);
|
||||
});
|
||||
|
||||
return () => void (isAlive = false);
|
||||
}, opts.deps);
|
||||
|
|
|
@ -277,6 +277,8 @@ export interface DefinedSettings<D extends SettingsDefinition = SettingsDefiniti
|
|||
* will be an empty string until plugin is initialized
|
||||
*/
|
||||
pluginName: string;
|
||||
|
||||
withPrivateSettings<T>(): this & { store: T; };
|
||||
}
|
||||
|
||||
export type PartialExcept<T, R extends keyof T> = Partial<T> & Required<Pick<T, R>>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue