refactor(response-modifier): rewrite modifiers with Typescript
Bug: twpowertools:230
Change-Id: Ibedccb24445098aae87fdbca94b0868bdcfccd41
diff --git a/src/xhrInterceptor/responseModifiers/createMessageRemoveParentRef.ts b/src/xhrInterceptor/responseModifiers/createMessageRemoveParentRef.ts
new file mode 100644
index 0000000..5fa59b5
--- /dev/null
+++ b/src/xhrInterceptor/responseModifiers/createMessageRemoveParentRef.ts
@@ -0,0 +1,18 @@
+import { Modifier } from "./types";
+
+const createMessageRemoveParentRef: Modifier = {
+ urlRegex: /api\/CreateMessage/i,
+ featureGated: true,
+ features: ['flattenthreads', 'flattenthreads_switch_enabled'],
+ isEnabled(options) {
+ return options['flattenthreads'] &&
+ options['flattenthreads_switch_enabled'];
+ },
+ async interceptor(response) {
+ // Remove parent_message_id value (field 37)
+ delete response[37];
+ return response;
+ }
+};
+
+export default createMessageRemoveParentRef;