1
0
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:
Iku-turso 2022-05-23 15:15:08 +03:00
parent 21e05d935b
commit fc6fc2488c
3 changed files with 18 additions and 13 deletions

View File

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

View File

@ -11,21 +11,17 @@ const askBooleanPromiseInjectable = getInjectable({
void questionId;
let resolve: (value: boolean) => void;
let _promise: Promise<boolean>;
const promise = new Promise<boolean>(_resolve => {
resolve = _resolve;
});
return ({
get promise() {
return _promise;
},
clear: () => {
_promise = new Promise(_resolve => {
resolve = _resolve;
});
},
promise,
resolve: (value: boolean) => {
resolve(value); },
resolve(value);
},
});
},

View File

@ -29,8 +29,6 @@ const askBooleanInjectable = getInjectable({
const returnValuePromise = di.inject(askBooleanPromiseInjectable, id);
returnValuePromise.clear();
await sendToChannel(askBooleanChannel, { id, title, question });
return await returnValuePromise.promise;