@inboxsdk/core 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inboxsdk.js +25 -192
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/pageWorld.js +3 -47
- package/pageWorld.js.map +1 -1
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +3 -8
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +4 -6
- package/src/inboxsdk-js/inboxsdk-REMOTE.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-REMOTE.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +2 -5
- package/src/inboxsdk-js/inboxsdk-TEST.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-TEST.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-TEST.js +5 -6
- package/src/inboxsdk-js/inboxsdk.d.ts +8 -0
- package/src/inboxsdk-js/inboxsdk.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk.js +22 -32
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.d.ts +2 -0
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.d.ts.map +1 -0
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +14 -16
- package/src/inboxsdk-js/loading/platform-implementation-loader.d.ts +1 -1
- package/src/inboxsdk-js/loading/platform-implementation-loader.d.ts.map +1 -1
- package/src/injected-js/gmail/setup-gmail-interceptor.js +7 -14
- package/src/injected-js/main.js +0 -9
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +0 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.js +2 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.test.js +10 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +39 -35
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +13 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +2 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +3 -4
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +7 -8
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +28 -31
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +4 -5
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.test.js +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +4 -5
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +3 -4
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +2 -3
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +5 -6
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +1 -2
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +4 -5
- package/src/platform-implementation-js/lib/idMap.d.ts +1 -2
- package/src/platform-implementation-js/lib/idMap.d.ts.map +1 -1
- package/src/platform-implementation-js/lib/idMap.js +4 -44
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.d.ts.map +1 -1
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.js +3 -4
- package/src/platform-implementation-js/lib/react/ElementContainer.js +3 -7
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.d.ts +3 -0
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.d.ts.map +1 -0
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +5 -9
- package/src/platform-implementation-js/main.d.ts +5 -0
- package/src/platform-implementation-js/main.d.ts.map +1 -0
- package/src/platform-implementation-js/main.js +38 -61
- package/src/platform-implementation-js/namespaces/conversations.js +2 -3
- package/src/platform-implementation-js/namespaces/lists.js +1 -2
- package/src/platform-implementation-js/namespaces/nav-menu.js +2 -3
- package/src/platform-implementation-js/namespaces/router.js +3 -4
- package/src/platform-implementation-js/namespaces/toolbars.js +1 -2
- package/src/platform-implementation-js/platform-implementation.d.ts +0 -3
- package/src/platform-implementation-js/platform-implementation.js +1 -11
- package/src/platform-implementation-js/views/app-menu-item-view.js +2 -1
- package/src/platform-implementation-js/views/collapsible-panel-view.js +2 -1
- package/src/platform-implementation-js/views/content-panel-view.js +1 -2
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +3 -4
- package/src/platform-implementation-js/views/conversations/message-view.js +1 -2
- package/src/platform-implementation-js/views/conversations/thread-view.js +1 -2
- package/src/platform-implementation-js/views/nav-item-view.js +1 -2
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +2 -3
- package/src/platform-implementation-js/widgets/drawer-view.js +1 -2
- package/src/platform-implementation-js/widgets/modal-view.js +1 -2
- package/src/platform-implementation-js/widgets/mole-view.js +1 -2
- package/src/injected-js/inbox/setupAjaxInterceptor.js +0 -211
- package/src/injected-js/inbox/setupClickAndGetNewIframeSrc.js +0 -67
- package/src/injected-js/inbox/setupComposeViewDraftIDFinder.js +0 -35
- package/src/injected-js/inbox/setupInboxFakeWindowResizeListener.js +0 -29
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts +0 -2
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts.map +0 -1
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +0 -17
- package/src/platform-implementation-js/dom-driver/inbox/__mocks__/getSidebarClassnames.js +0 -13
- package/src/platform-implementation-js/dom-driver/inbox/addNavItem.js +0 -38
- package/src/platform-implementation-js/dom-driver/inbox/addRecipientRow.js +0 -55
- package/src/platform-implementation-js/dom-driver/inbox/createLink.js +0 -19
- package/src/platform-implementation-js/dom-driver/inbox/createLink.test.js +0 -27
- package/src/platform-implementation-js/dom-driver/inbox/custom-style.js +0 -23
- package/src/platform-implementation-js/dom-driver/inbox/detection/appToolbarLocation/parser.js +0 -43
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentCard/parser.js +0 -34
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentOverlay/parser.js +0 -53
- package/src/platform-implementation-js/dom-driver/inbox/detection/chatSidebar/parser.js +0 -31
- package/src/platform-implementation-js/dom-driver/inbox/detection/compose/parser.js +0 -103
- package/src/platform-implementation-js/dom-driver/inbox/detection/message/parser.js +0 -69
- package/src/platform-implementation-js/dom-driver/inbox/detection/nativeDrawer/parser.js +0 -32
- package/src/platform-implementation-js/dom-driver/inbox/detection/searchBar/parser.js +0 -28
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread/parser.js +0 -49
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread-row/parser.js +0 -100
- package/src/platform-implementation-js/dom-driver/inbox/getComposeViewDriverLiveSet.js +0 -99
- package/src/platform-implementation-js/dom-driver/inbox/getInboxMessageIdForInboxThreadId.js +0 -36
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.js +0 -114
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.test.js +0 -73
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.js +0 -39
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.test.js +0 -28
- package/src/platform-implementation-js/dom-driver/inbox/inbox-butter-bar-driver.js +0 -148
- package/src/platform-implementation-js/dom-driver/inbox/inbox-driver.js +0 -866
- package/src/platform-implementation-js/dom-driver/inbox/inbox-page-communicator.js +0 -62
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.js +0 -12
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.test.js +0 -18
- package/src/platform-implementation-js/dom-driver/inbox/makePageParserTree.js +0 -33
- package/src/platform-implementation-js/dom-driver/inbox/pageParserOptions.js +0 -265
- package/src/platform-implementation-js/dom-driver/inbox/registerSearchSuggestionsProvider.js +0 -301
- package/src/platform-implementation-js/dom-driver/inbox/setupCustomAutocompleteSelectionHandling.js +0 -183
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.js +0 -64
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.test.js +0 -72
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxLabelView.js +0 -78
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxMoleViewDriver.js +0 -297
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarButtonView.js +0 -92
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarView.js +0 -54
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-sidebar-view.js +0 -272
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-button-view.js +0 -161
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-tooltip-view.js +0 -58
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-card-view.js +0 -198
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-overlay-view.js +0 -90
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-chat-sidebar-view.js +0 -46
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-button-view.js +0 -116
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-view.js +0 -843
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.js +0 -76
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.test.js +0 -31
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dropdown-view.js +0 -25
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dummy-route-view.js +0 -64
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-message-view.js +0 -275
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-modal-view.js +0 -113
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-route-view.js +0 -97
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-row-view.js +0 -316
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.js +0 -219
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.test.js +0 -171
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-tooltip-view.js +0 -128
- package/src/platform-implementation-js/dom-driver/inbox/views/inboxNavItemView.js +0 -312
- package/src/platform-implementation-js/dom-driver/inbox/waitForAnimationClickBlockerGone.js +0 -26
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts +0 -2
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts.map +0 -1
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +0 -4
- package/src/platform-implementation-js/lib/shared-style.js +0 -23
- package/src/types/gulp-add-src.d.ts +0 -7
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _ud = require("ud");
|
|
10
|
-
var _updateIcon = _interopRequireDefault(require("../../../driver-common/update-icon"));
|
|
11
|
-
var _autoHtml = _interopRequireDefault(require("auto-html"));
|
|
12
|
-
var _kefir = _interopRequireDefault(require("kefir"));
|
|
13
|
-
var _kefirBus = _interopRequireDefault(require("kefir-bus"));
|
|
14
|
-
var _kefirStopper = _interopRequireDefault(require("kefir-stopper"));
|
|
15
|
-
var _kefirCast = _interopRequireDefault(require("kefir-cast"));
|
|
16
|
-
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
17
|
-
var _InboxLabelView = _interopRequireDefault(require("./InboxLabelView"));
|
|
18
|
-
var _InboxToolbarButtonView = _interopRequireDefault(require("./InboxToolbarButtonView"));
|
|
19
|
-
class InboxThreadRowView {
|
|
20
|
-
constructor(element, driver, parsed) {
|
|
21
|
-
(0, _defineProperty2.default)(this, "_eventStream", (0, _kefirBus.default)());
|
|
22
|
-
(0, _defineProperty2.default)(this, "_isDestroyed", false);
|
|
23
|
-
this._element = element;
|
|
24
|
-
this._driver = driver;
|
|
25
|
-
this._p = parsed;
|
|
26
|
-
this._stopper = this._eventStream.ignoreValues().beforeEnd(() => null).toProperty();
|
|
27
|
-
}
|
|
28
|
-
getEventStream() {
|
|
29
|
-
return this._eventStream;
|
|
30
|
-
}
|
|
31
|
-
getStopper() {
|
|
32
|
-
return this._stopper;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// keeping this here for now since the rest of the system expects it.
|
|
36
|
-
// in Gmail it's used to pass a ThreadRowView interface to addButton()
|
|
37
|
-
// onClick callbacks, but not sure if it will be needed in the end.
|
|
38
|
-
setUserView(userView) {
|
|
39
|
-
this._userView = userView;
|
|
40
|
-
}
|
|
41
|
-
isSelected() {
|
|
42
|
-
if (!this._p.elements.checkbox) {
|
|
43
|
-
throw new Error('Did not find checkbox element');
|
|
44
|
-
}
|
|
45
|
-
return this._p.elements.checkbox.getAttribute('aria-checked') === 'true';
|
|
46
|
-
}
|
|
47
|
-
addToolbarButton(options) {
|
|
48
|
-
const {
|
|
49
|
-
toolbar
|
|
50
|
-
} = this._p.elements;
|
|
51
|
-
if (!toolbar) {
|
|
52
|
-
throw new Error('could not find toolbar element');
|
|
53
|
-
}
|
|
54
|
-
toolbar.classList.add('inboxsdk__list_toolbar');
|
|
55
|
-
const button = new _InboxToolbarButtonView.default({
|
|
56
|
-
...options,
|
|
57
|
-
onClick: event => {
|
|
58
|
-
if (event.dropdown) {
|
|
59
|
-
toolbar.classList.add('inboxsdk__thread_row_force_toolbar_visible');
|
|
60
|
-
event.dropdown.once('destroy', () => {
|
|
61
|
-
toolbar.classList.remove('inboxsdk__thread_row_force_toolbar_visible');
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (options.onClick) options.onClick(event);
|
|
65
|
-
}
|
|
66
|
-
}, this._driver.getAppId(), toolbar);
|
|
67
|
-
this._stopper.takeUntilBy(button.getStopper()).onValue(() => {
|
|
68
|
-
button.destroy();
|
|
69
|
-
});
|
|
70
|
-
return button;
|
|
71
|
-
}
|
|
72
|
-
addAttachmentIcon(options) {
|
|
73
|
-
throw new Error('Not supported in Inbox');
|
|
74
|
-
}
|
|
75
|
-
addButton(options) {
|
|
76
|
-
throw new Error('Not supported in Inbox');
|
|
77
|
-
}
|
|
78
|
-
addActionButton(options) {
|
|
79
|
-
throw new Error('not yet implemented');
|
|
80
|
-
}
|
|
81
|
-
addImage(icon) {
|
|
82
|
-
if (this._isDestroyed) {
|
|
83
|
-
console.warn('addImage called on destroyed thread row');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const {
|
|
87
|
-
labelParent
|
|
88
|
-
} = this._p.elements;
|
|
89
|
-
if (!labelParent) throw new Error('Could not find label parent element');
|
|
90
|
-
const prop = (0, _kefirCast.default)(_kefir.default, icon).takeUntilBy(this._stopper).toProperty();
|
|
91
|
-
let imageMod = null;
|
|
92
|
-
prop.onValue(iconDescriptor => {
|
|
93
|
-
if (!iconDescriptor) {
|
|
94
|
-
if (imageMod) {
|
|
95
|
-
imageMod.remove();
|
|
96
|
-
imageMod = null;
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
if (!imageMod) {
|
|
100
|
-
imageMod = {
|
|
101
|
-
iconSettings: {},
|
|
102
|
-
iconWrapper: document.createElement('div'),
|
|
103
|
-
remove() {
|
|
104
|
-
this.iconWrapper.remove();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
imageMod.iconWrapper.className = 'inboxsdk__thread_row_icon_wrapper';
|
|
108
|
-
}
|
|
109
|
-
const {
|
|
110
|
-
iconSettings,
|
|
111
|
-
iconWrapper
|
|
112
|
-
} = imageMod;
|
|
113
|
-
(0, _updateIcon.default)(iconSettings, iconWrapper, false, iconDescriptor.imageClass, iconDescriptor.imageUrl);
|
|
114
|
-
if (iconDescriptor.tooltip) {
|
|
115
|
-
iconWrapper.setAttribute('title', iconDescriptor.tooltip);
|
|
116
|
-
}
|
|
117
|
-
if (labelParent !== iconWrapper.parentElement) {
|
|
118
|
-
const threadLabels = labelParent.querySelectorAll('.inboxsdk__inbox_thread_row_label');
|
|
119
|
-
const insertionPoint = threadLabels.length > 0 ? threadLabels[threadLabels.length - 1].nextElementSibling : labelParent.firstChild;
|
|
120
|
-
labelParent.insertBefore(iconWrapper, insertionPoint);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
this._stopper.onEnd(() => {
|
|
125
|
-
if (imageMod) {
|
|
126
|
-
imageMod.remove();
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
addLabel(label) {
|
|
131
|
-
if (this._isDestroyed) {
|
|
132
|
-
console.warn('addLabel called on destroyed thread row');
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const labelParentDiv = this._p.elements.labelParent;
|
|
136
|
-
if (!labelParentDiv) throw new Error('Could not find label parent element');
|
|
137
|
-
const prop = (0, _kefirCast.default)(_kefir.default, label).takeUntilBy(this._stopper).toProperty();
|
|
138
|
-
let labelMod = null;
|
|
139
|
-
prop.onValue(labelDescriptor => {
|
|
140
|
-
if (!labelDescriptor) {
|
|
141
|
-
if (labelMod) {
|
|
142
|
-
labelMod.remove();
|
|
143
|
-
labelMod = null;
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
if (!labelMod) {
|
|
147
|
-
const inboxLabelView = new _InboxLabelView.default();
|
|
148
|
-
const el = inboxLabelView.getElement();
|
|
149
|
-
labelMod = {
|
|
150
|
-
inboxLabelView,
|
|
151
|
-
remove: el.remove.bind(el)
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
labelMod.inboxLabelView.updateLabelDescriptor(labelDescriptor);
|
|
155
|
-
if (labelParentDiv !== labelMod.inboxLabelView.getElement().parentElement) {
|
|
156
|
-
const threadLabels = labelParentDiv.querySelectorAll('.inboxsdk__inbox_thread_row_label');
|
|
157
|
-
const insertionPoint = threadLabels.length > 0 ? threadLabels[threadLabels.length - 1].nextElementSibling : labelParentDiv.firstChild;
|
|
158
|
-
labelParentDiv.insertBefore(labelMod.inboxLabelView.getElement(), insertionPoint);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
this._stopper.onEnd(() => {
|
|
163
|
-
if (labelMod) {
|
|
164
|
-
labelMod.remove();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
getDateString() {
|
|
169
|
-
throw new Error('Not supported in Inbox');
|
|
170
|
-
}
|
|
171
|
-
getSubject() {
|
|
172
|
-
if (!this._p.elements.subject) {
|
|
173
|
-
throw new Error('Failed to find subject');
|
|
174
|
-
}
|
|
175
|
-
return this._p.elements.subject.textContent;
|
|
176
|
-
}
|
|
177
|
-
getThreadID() {
|
|
178
|
-
throw new Error('Not supported in Inbox. Please use getThreadIDAsync() instead');
|
|
179
|
-
}
|
|
180
|
-
async getThreadIDAsync() {
|
|
181
|
-
const {
|
|
182
|
-
inboxThreadId
|
|
183
|
-
} = this._p.attributes;
|
|
184
|
-
if (!inboxThreadId) {
|
|
185
|
-
throw new Error('Failed to find thread id');
|
|
186
|
-
}
|
|
187
|
-
if (/^thread-a:/.test(inboxThreadId)) {
|
|
188
|
-
this._driver.trackThreadRowIdCall(false, inboxThreadId);
|
|
189
|
-
// Get the inbox message id of any message in the thread, convert it to
|
|
190
|
-
// a gmail message id, and then use that id in a request
|
|
191
|
-
// to a gmail endpoint to get the id of the thread that message is in.
|
|
192
|
-
const inboxMessageId = await this._driver.getInboxMessageIdForInboxThreadId(inboxThreadId);
|
|
193
|
-
const gmailMessageId = await this._driver.getGmailMessageIdForSyncMessageId(inboxMessageId);
|
|
194
|
-
return await this._driver.getThreadIdFromMessageId(gmailMessageId);
|
|
195
|
-
} else {
|
|
196
|
-
this._driver.trackThreadRowIdCall(true, inboxThreadId);
|
|
197
|
-
const m = /\d+$/.exec(inboxThreadId);
|
|
198
|
-
if (!m) throw new Error('Should not happen');
|
|
199
|
-
return new _bignumber.default(m[0]).toString(16);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
async getDraftID() {
|
|
203
|
-
const {
|
|
204
|
-
isOnlyDraft,
|
|
205
|
-
inboxThreadId
|
|
206
|
-
} = this._p.attributes;
|
|
207
|
-
if (isOnlyDraft && inboxThreadId) {
|
|
208
|
-
const m = /\d+$/.exec(inboxThreadId);
|
|
209
|
-
if (!m) throw new Error('Should not happen');
|
|
210
|
-
return m[0];
|
|
211
|
-
} else {
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
getVisibleDraftCount() {
|
|
216
|
-
const {
|
|
217
|
-
visibleDraftCount
|
|
218
|
-
} = this._p.attributes;
|
|
219
|
-
if (typeof visibleDraftCount !== 'number') throw new Error('Failed to find visible draft count');
|
|
220
|
-
return visibleDraftCount;
|
|
221
|
-
}
|
|
222
|
-
getVisibleMessageCount() {
|
|
223
|
-
const {
|
|
224
|
-
visibleMessageCount
|
|
225
|
-
} = this._p.attributes;
|
|
226
|
-
if (typeof visibleMessageCount !== 'number') throw new Error('Failed to find visible message count');
|
|
227
|
-
return visibleMessageCount;
|
|
228
|
-
}
|
|
229
|
-
getContacts() {
|
|
230
|
-
const {
|
|
231
|
-
contacts
|
|
232
|
-
} = this._p.attributes;
|
|
233
|
-
if (!Array.isArray(contacts)) throw new Error('Failed to find contacts');
|
|
234
|
-
return contacts;
|
|
235
|
-
}
|
|
236
|
-
replaceDate(options) {
|
|
237
|
-
throw new Error('Not supported in Inbox');
|
|
238
|
-
}
|
|
239
|
-
replaceDraftLabel(label) {
|
|
240
|
-
if (this._isDestroyed) {
|
|
241
|
-
console.warn('addLabel called on destroyed thread row');
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// We don't want to replace draft labels on messages without drafts
|
|
246
|
-
if (this._p.attributes.visibleDraftCount === 0) return;
|
|
247
|
-
const {
|
|
248
|
-
recipientParent,
|
|
249
|
-
messageCountParent
|
|
250
|
-
} = this._p.elements;
|
|
251
|
-
if (!recipientParent || !messageCountParent) throw new Error('Could not find necessary parent elements');
|
|
252
|
-
const prop = (0, _kefirCast.default)(_kefir.default, label).takeUntilBy(this._stopper).toProperty();
|
|
253
|
-
let labelMod = null;
|
|
254
|
-
prop.onValue(labelDescriptor => {
|
|
255
|
-
if (!labelDescriptor) {
|
|
256
|
-
if (labelMod) {
|
|
257
|
-
labelMod.remove();
|
|
258
|
-
labelMod = null;
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
const {
|
|
262
|
-
text,
|
|
263
|
-
count
|
|
264
|
-
} = labelDescriptor;
|
|
265
|
-
if (!labelMod) {
|
|
266
|
-
labelMod = {
|
|
267
|
-
countEl: document.createElement('span'),
|
|
268
|
-
draftEl: document.createElement('span'),
|
|
269
|
-
remove() {
|
|
270
|
-
this.countEl.remove();
|
|
271
|
-
this.draftEl.remove();
|
|
272
|
-
recipientParent.classList.remove('inboxsdk__thread_row_draft_label_replaced');
|
|
273
|
-
messageCountParent.classList.remove('inboxsdk__thread_row_draft_count_replaced');
|
|
274
|
-
if (!messageCountParent.querySelector('span:not(.inboxsdk__thread_row_custom_draft_count)')) {
|
|
275
|
-
messageCountParent.style.display = 'none';
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
labelMod.draftEl.className = 'inboxsdk__thread_row_custom_draft_label';
|
|
280
|
-
labelMod.countEl.className = 'inboxsdk__thread_row_custom_draft_count';
|
|
281
|
-
recipientParent.classList.add('inboxsdk__thread_row_draft_label_replaced');
|
|
282
|
-
}
|
|
283
|
-
labelMod.draftEl.textContent = text;
|
|
284
|
-
if (recipientParent !== labelMod.draftEl.parentElement) {
|
|
285
|
-
recipientParent.appendChild(labelMod.draftEl);
|
|
286
|
-
}
|
|
287
|
-
const hasExistingCountEl = messageCountParent.querySelector('span:not(.inboxsdk__thread_row_custom_draft_count)');
|
|
288
|
-
if (count && count > 1) {
|
|
289
|
-
messageCountParent.classList.add('inboxsdk__thread_row_draft_count_replaced');
|
|
290
|
-
messageCountParent.style.display = 'inline';
|
|
291
|
-
labelMod.countEl.innerHTML = hasExistingCountEl ? (0, _autoHtml.default)`(${count})` : (0, _autoHtml.default)` (${count})`;
|
|
292
|
-
if (messageCountParent !== labelMod.countEl.parentElement) {
|
|
293
|
-
messageCountParent.appendChild(labelMod.countEl);
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
messageCountParent.classList.remove('inboxsdk__thread_row_draft_count_replaced');
|
|
297
|
-
if (!hasExistingCountEl) {
|
|
298
|
-
messageCountParent.style.display = 'none';
|
|
299
|
-
}
|
|
300
|
-
labelMod.countEl.remove();
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
this._stopper.onEnd(() => {
|
|
304
|
-
if (labelMod) {
|
|
305
|
-
labelMod.remove();
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
destroy() {
|
|
311
|
-
this._isDestroyed = true;
|
|
312
|
-
this._eventStream.end();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
var _default = (0, _ud.defn)(module, InboxThreadRowView);
|
|
316
|
-
exports.default = _default;
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _find = _interopRequireDefault(require("lodash/find"));
|
|
10
|
-
var _ud = require("ud");
|
|
11
|
-
var _autoHtml = _interopRequireDefault(require("auto-html"));
|
|
12
|
-
var _kefir = _interopRequireDefault(require("kefir"));
|
|
13
|
-
var _kefirBus = _interopRequireDefault(require("kefir-bus"));
|
|
14
|
-
var _kefirStopper = _interopRequireDefault(require("kefir-stopper"));
|
|
15
|
-
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
16
|
-
var _delayAsap = _interopRequireDefault(require("../../../lib/delay-asap"));
|
|
17
|
-
var _idMap = _interopRequireDefault(require("../../../lib/idMap"));
|
|
18
|
-
var _querySelectorOrFail = _interopRequireDefault(require("../../../lib/dom/querySelectorOrFail"));
|
|
19
|
-
var _makeMutationObserverChunkedStream = _interopRequireDefault(require("../../../lib/dom/make-mutation-observer-chunked-stream"));
|
|
20
|
-
var _SimpleElementView = _interopRequireDefault(require("../../../views/SimpleElementView"));
|
|
21
|
-
var _customMessageView = _interopRequireDefault(require("../../../views/conversations/custom-message-view"));
|
|
22
|
-
var _parser = _interopRequireDefault(require("../detection/thread/parser"));
|
|
23
|
-
class InboxThreadView {
|
|
24
|
-
constructor(element, driver, parsed) {
|
|
25
|
-
(0, _defineProperty2.default)(this, "_eventStream", (0, _kefirBus.default)());
|
|
26
|
-
(0, _defineProperty2.default)(this, "_messageViews", []);
|
|
27
|
-
(0, _defineProperty2.default)(this, "_receivedMessageView", (0, _kefirStopper.default)());
|
|
28
|
-
(0, _defineProperty2.default)(this, "_sidebarPanels", new Set());
|
|
29
|
-
this._element = element;
|
|
30
|
-
this._driver = driver;
|
|
31
|
-
this._p = parsed;
|
|
32
|
-
this._stopper = this._eventStream.ignoreValues().beforeEnd(() => null).toProperty();
|
|
33
|
-
this._driver.getThreadViewElementsMap().set(this._element, this);
|
|
34
|
-
this._ready = this._receivedMessageView.flatMap(() => (0, _delayAsap.default)()).onValue(() => {
|
|
35
|
-
this._p = (0, _parser.default)(this._element);
|
|
36
|
-
}).toProperty();
|
|
37
|
-
if (this.isLoadingStub()) {
|
|
38
|
-
(0, _makeMutationObserverChunkedStream.default)(this._element, {
|
|
39
|
-
attributes: true,
|
|
40
|
-
attributeFilter: ['aria-busy']
|
|
41
|
-
}).takeUntilBy(this._stopper).onValue(() => {
|
|
42
|
-
if (!this.isLoadingStub()) {
|
|
43
|
-
this.destroy();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
isLoadingStub() {
|
|
49
|
-
return this._element.getAttribute('aria-busy') === 'true';
|
|
50
|
-
}
|
|
51
|
-
getEventStream() {
|
|
52
|
-
return this._eventStream;
|
|
53
|
-
}
|
|
54
|
-
getStopper() {
|
|
55
|
-
return this._stopper;
|
|
56
|
-
}
|
|
57
|
-
addMessageViewDriver(messageView) {
|
|
58
|
-
this._messageViews.push(messageView);
|
|
59
|
-
this._eventStream.plug(messageView.getEventStream().filter(event => event.eventName === 'contactHover'));
|
|
60
|
-
messageView.getStopper().takeUntilBy(this._stopper).onValue(() => {
|
|
61
|
-
this._messageViews = this._messageViews.filter(m => m !== messageView);
|
|
62
|
-
});
|
|
63
|
-
this._receivedMessageView.destroy();
|
|
64
|
-
}
|
|
65
|
-
getMessageViewDrivers() {
|
|
66
|
-
return this._messageViews;
|
|
67
|
-
}
|
|
68
|
-
getToolbarElement() {
|
|
69
|
-
if (!this._p.elements.toolbar) {
|
|
70
|
-
throw new Error('Failed to find toolbar');
|
|
71
|
-
}
|
|
72
|
-
return this._p.elements.toolbar;
|
|
73
|
-
}
|
|
74
|
-
getSubject() {
|
|
75
|
-
if (!this._p.elements.heading) {
|
|
76
|
-
throw new Error('Failed to find subject');
|
|
77
|
-
}
|
|
78
|
-
return this._p.elements.heading.textContent;
|
|
79
|
-
}
|
|
80
|
-
getThreadID() {
|
|
81
|
-
const {
|
|
82
|
-
inboxThreadId
|
|
83
|
-
} = this._p.attributes;
|
|
84
|
-
if (!inboxThreadId) {
|
|
85
|
-
throw new Error('Failed to find thread id');
|
|
86
|
-
}
|
|
87
|
-
if (/^msg-a:/.test(inboxThreadId)) {
|
|
88
|
-
console.warn('ThreadView.getThreadID() returned an incorrect thread ID. This method will be deprecated soon. Use getThreadIDAsync() instead which does not have this problem.');
|
|
89
|
-
}
|
|
90
|
-
const m = /\d+$/.exec(inboxThreadId);
|
|
91
|
-
if (!m) throw new Error('Should not happen');
|
|
92
|
-
return new _bignumber.default(m[0]).toString(16);
|
|
93
|
-
}
|
|
94
|
-
async getThreadIDAsync() {
|
|
95
|
-
const {
|
|
96
|
-
inboxThreadId
|
|
97
|
-
} = this._p.attributes;
|
|
98
|
-
if (!inboxThreadId) {
|
|
99
|
-
throw new Error('Failed to find message id');
|
|
100
|
-
}
|
|
101
|
-
if (/^thread-a:/.test(inboxThreadId)) {
|
|
102
|
-
// Get the id of any message in the thread, and then use that id in a request
|
|
103
|
-
// to a gmail endpoint to get the id of the thread that message is in.
|
|
104
|
-
const firstMessage = this._messageViews[0];
|
|
105
|
-
if (!firstMessage) throw new Error('Should not happen');
|
|
106
|
-
const messageId = await firstMessage.getMessageIDAsync();
|
|
107
|
-
return await this._driver.getThreadIdFromMessageId(messageId);
|
|
108
|
-
} else {
|
|
109
|
-
const m = /\d+$/.exec(inboxThreadId);
|
|
110
|
-
if (!m) throw new Error('Should not happen');
|
|
111
|
-
return new _bignumber.default(m[0]).toString(16);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
registerHiddenCustomMessageNoticeProvider(provider) {
|
|
115
|
-
throw new Error('not supported');
|
|
116
|
-
}
|
|
117
|
-
addCustomMessage(descriptorStream) {
|
|
118
|
-
throw new Error('not supported');
|
|
119
|
-
}
|
|
120
|
-
addSidebarContentPanel(descriptor) {
|
|
121
|
-
const panel = this._driver.getAppSidebarView().addSidebarContentPanel(descriptor);
|
|
122
|
-
this._sidebarPanels.add(panel);
|
|
123
|
-
panel.getStopper().onValue(() => {
|
|
124
|
-
this._sidebarPanels.delete(panel);
|
|
125
|
-
});
|
|
126
|
-
this._stopper.takeUntilBy(panel.getStopper()).onValue(() => {
|
|
127
|
-
panel.remove();
|
|
128
|
-
});
|
|
129
|
-
descriptor.takeUntilBy(this._stopper).takeUntilBy(panel.getStopper()).take(1).onValue(descriptor => {
|
|
130
|
-
const {
|
|
131
|
-
stickyHeading
|
|
132
|
-
} = this._p.elements;
|
|
133
|
-
if (!stickyHeading) return;
|
|
134
|
-
let iconArea = stickyHeading.querySelector('.' + (0, _idMap.default)('sidebar_iconArea'));
|
|
135
|
-
if (!iconArea) {
|
|
136
|
-
const _iconArea = iconArea = document.createElement('div');
|
|
137
|
-
iconArea.className = (0, _idMap.default)('sidebar_iconArea');
|
|
138
|
-
this._driver.getAppSidebarView().getOpenOrOpeningStream().takeUntilBy(this._stopper).onValue(open => {
|
|
139
|
-
_iconArea.style.display = open ? 'none' : '';
|
|
140
|
-
});
|
|
141
|
-
stickyHeading.appendChild(iconArea);
|
|
142
|
-
}
|
|
143
|
-
const appName = descriptor.appName || this._driver.getOpts().appName || descriptor.title;
|
|
144
|
-
const appIconUrl = descriptor.appIconUrl || this._driver.getOpts().appIconUrl || descriptor.iconUrl;
|
|
145
|
-
|
|
146
|
-
// If there's an existing button for the app, then just increment its
|
|
147
|
-
// data-count attribute instead of adding a new button.
|
|
148
|
-
const existingButtonContainer = (0, _find.default)(iconArea.querySelectorAll('.' + (0, _idMap.default)('sidebar_button_container')), el => {
|
|
149
|
-
const button = el.querySelector('button');
|
|
150
|
-
if (!button || button.title !== appName) return false;
|
|
151
|
-
const img = button.querySelector('img');
|
|
152
|
-
if (!img || img.src !== appIconUrl) return false;
|
|
153
|
-
return true;
|
|
154
|
-
});
|
|
155
|
-
let container;
|
|
156
|
-
if (existingButtonContainer) {
|
|
157
|
-
const currentCount = Number(existingButtonContainer.getAttribute('data-count')) || 1;
|
|
158
|
-
existingButtonContainer.setAttribute('data-count', currentCount + 1);
|
|
159
|
-
container = existingButtonContainer;
|
|
160
|
-
} else {
|
|
161
|
-
container = document.createElement('div');
|
|
162
|
-
container.className = (0, _idMap.default)('sidebar_button_container');
|
|
163
|
-
container.innerHTML = (0, _autoHtml.default)`
|
|
164
|
-
<button class="inboxsdk__button_icon" type="button" title="${appName}">
|
|
165
|
-
<img class="inboxsdk__button_iconImg" src="${appIconUrl}">
|
|
166
|
-
</button>
|
|
167
|
-
`;
|
|
168
|
-
(0, _querySelectorOrFail.default)(container, 'button').addEventListener('click', event => {
|
|
169
|
-
event.stopPropagation();
|
|
170
|
-
this._driver.getAppSidebarView().open();
|
|
171
|
-
panel.scrollIntoView();
|
|
172
|
-
}, true);
|
|
173
|
-
iconArea.appendChild(container);
|
|
174
|
-
}
|
|
175
|
-
panel.getStopper().onValue(() => {
|
|
176
|
-
const currentCount = Number(container.getAttribute('data-count'));
|
|
177
|
-
if (currentCount <= 1) {
|
|
178
|
-
container.remove();
|
|
179
|
-
} else if (currentCount === 2) {
|
|
180
|
-
container.removeAttribute('data-count');
|
|
181
|
-
} else {
|
|
182
|
-
container.setAttribute('data-count', String(currentCount - 1));
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
return panel;
|
|
187
|
-
}
|
|
188
|
-
removePanels() {
|
|
189
|
-
this._sidebarPanels.forEach(panel => {
|
|
190
|
-
panel.remove();
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
addNoticeBar() {
|
|
194
|
-
const el = document.createElement('div');
|
|
195
|
-
el.className = (0, _idMap.default)('thread_noticeBar');
|
|
196
|
-
const {
|
|
197
|
-
heading
|
|
198
|
-
} = this._p.elements;
|
|
199
|
-
if (!heading) {
|
|
200
|
-
throw new Error('Failed to find subject');
|
|
201
|
-
}
|
|
202
|
-
heading.insertAdjacentElement('afterend', el);
|
|
203
|
-
const view = new _SimpleElementView.default(el);
|
|
204
|
-
this._stopper.takeUntilBy(_kefir.default.fromEvents(view, 'destroy')).onValue(() => view.destroy());
|
|
205
|
-
return view;
|
|
206
|
-
}
|
|
207
|
-
addLabel() {
|
|
208
|
-
throw new Error('not supported');
|
|
209
|
-
}
|
|
210
|
-
getReadyStream() {
|
|
211
|
-
return this._ready;
|
|
212
|
-
}
|
|
213
|
-
destroy() {
|
|
214
|
-
this._driver.getThreadViewElementsMap().delete(this._element);
|
|
215
|
-
this._eventStream.end();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
var _default = (0, _ud.defn)(module, InboxThreadView);
|
|
219
|
-
exports.default = _default;
|