Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3490718
D5828.id19385.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5828.id19385.diff
View Options
diff --git a/lib/utils/policy-acknowledge-utlis.js b/lib/utils/policy-acknowledge-utlis.js
new file mode 100644
--- /dev/null
+++ b/lib/utils/policy-acknowledge-utlis.js
@@ -0,0 +1,32 @@
+// @flow
+
+import { policyAcknowledgmentActionTypes } from '../actions/user-actions.js';
+import type { PolicyType } from '../facts/policies.js';
+import type { PolicyAcknowledgmentRequest } from '../types/account-types.js';
+import type { DispatchActionPromise } from './action-utils.js';
+
+function acknowledgePolicy(
+ policy: PolicyType,
+ dispatchActionPromise: DispatchActionPromise,
+ acknowledgmentServerCall: (
+ request: PolicyAcknowledgmentRequest,
+ ) => Promise<void>,
+ onError: (message: string) => void,
+) {
+ const acknowledgePolicyPromise = (async () => {
+ try {
+ await acknowledgmentServerCall({ policy });
+ return { policy };
+ } catch (e) {
+ console.warn('error acknowledging policy', e);
+ onError('unknown error');
+ throw e;
+ }
+ })();
+ dispatchActionPromise(
+ policyAcknowledgmentActionTypes,
+ acknowledgePolicyPromise,
+ );
+}
+
+export { acknowledgePolicy };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:15 PM (18 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2677608
Default Alt Text
D5828.id19385.diff (1 KB)
Attached To
Mode
D5828: [lib] client function to call server and acknowledge policy
Attached
Detach File
Event Timeline
Log In to Comment