ReviewDB: Add Review Modal & Pagination (#1174)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
Manti 2023-05-28 23:03:06 +03:00 committed by GitHub
parent 6300198a54
commit 3e3d05fc26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 803 additions and 394 deletions

View file

@ -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);

View file

@ -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>>;