mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify code for asking of boolean value from user
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
21e05d935b
commit
fc6fc2488c
@ -0,0 +1,11 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`selection of update stability when started renders 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="Notifications flex column align-flex-end"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
@ -11,21 +11,17 @@ const askBooleanPromiseInjectable = getInjectable({
|
|||||||
void questionId;
|
void questionId;
|
||||||
|
|
||||||
let resolve: (value: boolean) => void;
|
let resolve: (value: boolean) => void;
|
||||||
let _promise: Promise<boolean>;
|
|
||||||
|
const promise = new Promise<boolean>(_resolve => {
|
||||||
|
resolve = _resolve;
|
||||||
|
});
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
get promise() {
|
promise,
|
||||||
return _promise;
|
|
||||||
},
|
|
||||||
|
|
||||||
clear: () => {
|
|
||||||
_promise = new Promise(_resolve => {
|
|
||||||
resolve = _resolve;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
resolve: (value: boolean) => {
|
resolve: (value: boolean) => {
|
||||||
resolve(value); },
|
resolve(value);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -29,8 +29,6 @@ const askBooleanInjectable = getInjectable({
|
|||||||
|
|
||||||
const returnValuePromise = di.inject(askBooleanPromiseInjectable, id);
|
const returnValuePromise = di.inject(askBooleanPromiseInjectable, id);
|
||||||
|
|
||||||
returnValuePromise.clear();
|
|
||||||
|
|
||||||
await sendToChannel(askBooleanChannel, { id, title, question });
|
await sendToChannel(askBooleanChannel, { id, title, question });
|
||||||
|
|
||||||
return await returnValuePromise.promise;
|
return await returnValuePromise.promise;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user