@inboxsdk/core 1.0.1 → 1.0.3
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 +5 -5
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/pageWorld.js.map +1 -1
- package/src/inboxsdk.d.ts +16 -1
- package/src/injected-js/gmail/modify-suggestions.d.ts +2 -0
- package/src/injected-js/gmail/modify-suggestions.d.ts.map +1 -1
- package/src/platform-implementation-js/constants/router.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts +2 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +16 -21
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.d.ts +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +152 -187
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.d.ts +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.js +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +15 -20
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +59 -56
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +42 -54
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +31 -33
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +21 -23
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +19 -31
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +51 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.d.ts +20 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +166 -130
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +44 -51
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +136 -129
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.d.ts +6 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +102 -95
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.d.ts +6 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +144 -169
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +14 -23
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +41 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +286 -294
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +19 -26
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +36 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +34 -33
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.d.ts +13 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +80 -81
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +124 -81
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.d.ts +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +47 -54
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts +183 -106
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +712 -647
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +93 -82
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.d.ts +11 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +20 -32
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.d.ts +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.d.ts +2 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.js +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +3 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.d.ts +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.d.ts +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.d.ts +20 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +107 -108
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.d.ts +16 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.d.ts +13 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +66 -66
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.d.ts +5 -0
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.d.ts +6 -0
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.d.ts +6 -0
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.d.ts +1 -0
- package/src/platform-implementation-js/driver-interfaces/driver.d.ts +3 -6
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.d.ts +27 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.d.ts +4 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +34 -34
- package/src/platform-implementation-js/lib/dom/element-view-mapper.d.ts +10 -0
- package/src/platform-implementation-js/lib/dom/element-view-mapper.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +9 -17
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.d.ts +4 -0
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +7 -16
- package/src/platform-implementation-js/lib/populateRouteID.d.ts +6 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts +2 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +4 -11
- package/src/platform-implementation-js/lib/routeIDmatchesHash.d.ts +4 -0
- package/src/platform-implementation-js/lib/toLiveSet.d.ts +5 -0
- package/src/platform-implementation-js/lib/toLiveSet.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/toLiveSet.js +22 -33
- package/src/platform-implementation-js/namespaces/router.d.ts +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.test.js +0 -183
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.test.js +0 -218
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.test.js +0 -85
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.test.js +0 -43
|
@@ -1,661 +1,726 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _createLink = _interopRequireDefault(require("./gmail-driver/create-link"));
|
|
58
|
-
var _registerSearchQueryRewriter = _interopRequireDefault(require("./gmail-driver/register-search-query-rewriter"));
|
|
59
|
-
var _openComposeWindow = _interopRequireDefault(require("./gmail-driver/open-compose-window"));
|
|
60
|
-
var _gmailAppSidebarView = _interopRequireDefault(require("./views/gmail-app-sidebar-view"));
|
|
61
|
-
var _suppressAddon = _interopRequireDefault(require("./gmail-driver/suppressAddon"));
|
|
62
|
-
var _getSyncThreadFromSyncThreadId = _interopRequireDefault(require("./gmail-driver/getSyncThreadFromSyncThreadId"));
|
|
63
|
-
var _getSyncThreadForOldGmailThreadId = _interopRequireDefault(require("./gmail-driver/getSyncThreadForOldGmailThreadId"));
|
|
64
|
-
var _toItemWithLifetimeStream = _interopRequireDefault(require("../../lib/toItemWithLifetimeStream"));
|
|
65
|
-
var _toLiveSet = _interopRequireDefault(require("../../lib/toLiveSet"));
|
|
66
|
-
var _streamWaitFor = _interopRequireDefault(require("../../lib/stream-wait-for"));
|
|
67
|
-
var _waitFor = _interopRequireDefault(require("../../lib/wait-for"));
|
|
68
|
-
var _gmailNavItemView = _interopRequireDefault(require("./views/gmail-nav-item-view"));
|
|
1
|
+
import toValueObservable from 'live-set/toValueObservable';
|
|
2
|
+
import t from 'transducers.js';
|
|
3
|
+
import * as Kefir from 'kefir';
|
|
4
|
+
import kefirStopper from 'kefir-stopper';
|
|
5
|
+
import kefirBus from 'kefir-bus';
|
|
6
|
+
import includes from 'lodash/includes';
|
|
7
|
+
import get from '../../../common/get-or-fail';
|
|
8
|
+
import showAppIdWarning from './gmail-driver/show-app-id-warning';
|
|
9
|
+
import makePageParserTree from './makePageParserTree';
|
|
10
|
+
import GmailElementGetter from './gmail-element-getter';
|
|
11
|
+
import makeXhrInterceptor from './make-xhr-interceptor';
|
|
12
|
+
import GmailBackdrop from './views/gmail-backdrop';
|
|
13
|
+
import { removeAllThreadRowUnclaimedModifications } from './views/gmail-thread-row-view';
|
|
14
|
+
import GmailTopMessageBarDriver from './widgets/gmail-top-message-bar-driver';
|
|
15
|
+
import GmailModalViewDriver from './widgets/gmail-modal-view-driver';
|
|
16
|
+
import GmailMoleViewDriver from './widgets/gmail-mole-view-driver';
|
|
17
|
+
import InboxDrawerView from '../inbox/views/inbox-drawer-view';
|
|
18
|
+
import GmailRouteProcessor from './views/gmail-route-view/gmail-route-processor';
|
|
19
|
+
import KeyboardShortcutHelpModifier from './gmail-driver/keyboard-shortcut-help-modifier';
|
|
20
|
+
import openDraftByMessageID from './gmail-driver/open-draft-by-message-id';
|
|
21
|
+
import UserInfo from './gmail-driver/user-info';
|
|
22
|
+
import GmailButterBarDriver from './gmail-butter-bar-driver';
|
|
23
|
+
import trackGmailStyles from './gmail-driver/track-gmail-styles';
|
|
24
|
+
import temporaryTrackDownloadUrlValidity from './gmail-driver/temporary-track-download-url-validity';
|
|
25
|
+
import getGmailThreadIdForRfcMessageId from '../../driver-common/getGmailThreadIdForRfcMessageId';
|
|
26
|
+
import getRfcMessageIdForGmailThreadId from './gmail-driver/get-rfc-message-id-for-gmail-thread-id';
|
|
27
|
+
import getGmailMessageIdForSyncMessageId from '../../driver-common/getGmailMessageIdForSyncMessageId';
|
|
28
|
+
import BiMapCache from 'bimapcache';
|
|
29
|
+
import getDraftIDForMessageID from './gmail-driver/get-draft-id-for-message-id';
|
|
30
|
+
import addNavItem from './gmail-driver/add-nav-item';
|
|
31
|
+
import { addAppMenuItem } from './gmail-driver/add-app-menu-item';
|
|
32
|
+
import addSupportItem from './gmail-driver/add-support-item';
|
|
33
|
+
import gotoView from './gmail-driver/goto-view';
|
|
34
|
+
import showCustomThreadList from './gmail-driver/show-custom-thread-list';
|
|
35
|
+
import showCustomRouteView from './gmail-driver/show-custom-route-view';
|
|
36
|
+
import showNativeRouteView from './gmail-driver/show-native-route-view';
|
|
37
|
+
import registerSearchSuggestionsProvider from './gmail-driver/register-search-suggestions-provider';
|
|
38
|
+
import setupComposeViewDriverStream from './gmail-driver/setup-compose-view-driver-stream';
|
|
39
|
+
import trackEvents from './gmail-driver/track-events';
|
|
40
|
+
import gmailLoadEvent from './gmail-driver/gmail-load-event';
|
|
41
|
+
import ThreadRowIdentifier from './gmail-driver/thread-row-identifier';
|
|
42
|
+
import customStyle from './custom-style';
|
|
43
|
+
import overrideGmailBackButton from './gmail-driver/override-gmail-back-button';
|
|
44
|
+
import addToolbarButtonForApp from './gmail-driver/add-toolbar-button-for-app';
|
|
45
|
+
import setupRouteViewDriverStream from './gmail-driver/setup-route-view-driver-stream';
|
|
46
|
+
import getNativeNavItem from './gmail-driver/get-native-nav-item';
|
|
47
|
+
import createLink from './gmail-driver/create-link';
|
|
48
|
+
import registerSearchQueryRewriter from './gmail-driver/register-search-query-rewriter';
|
|
49
|
+
import openComposeWindow from './gmail-driver/open-compose-window';
|
|
50
|
+
import GmailAppSidebarView from './views/gmail-app-sidebar-view';
|
|
51
|
+
import suppressAddon from './gmail-driver/suppressAddon';
|
|
52
|
+
import getSyncThreadFromSyncThreadId from './gmail-driver/getSyncThreadFromSyncThreadId';
|
|
53
|
+
import getSyncThreadForOldGmailThreadId from './gmail-driver/getSyncThreadForOldGmailThreadId';
|
|
54
|
+
import toItemWithLifetimeStream from '../../lib/toItemWithLifetimeStream';
|
|
55
|
+
import toLiveSet from '../../lib/toLiveSet';
|
|
56
|
+
import waitFor from '../../lib/stream-wait-for';
|
|
69
57
|
class GmailDriver {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
58
|
+
_appId;
|
|
59
|
+
_logger;
|
|
60
|
+
_opts;
|
|
61
|
+
_envData;
|
|
62
|
+
_customRouteIDs = new Set();
|
|
63
|
+
_customListRouteIDs = new Map();
|
|
64
|
+
_customListSearchStringsToRouteIds = new Map();
|
|
65
|
+
_messageIDsToThreadIDs = new Map();
|
|
66
|
+
_threadRowIdentifier;
|
|
67
|
+
_gmailRouteProcessor;
|
|
68
|
+
_keyboardShortcutHelpModifier;
|
|
69
|
+
onready;
|
|
70
|
+
_page;
|
|
71
|
+
_pageCommunicator;
|
|
72
|
+
_pageCommunicatorPromise;
|
|
73
|
+
_butterBar;
|
|
74
|
+
_butterBarDriver;
|
|
75
|
+
_routeViewDriverStream;
|
|
76
|
+
_rowListViewDriverStream;
|
|
77
|
+
_threadRowViewDriverKefirStream;
|
|
78
|
+
_threadViewDriverLiveSet;
|
|
79
|
+
_toolbarViewDriverLiveSet;
|
|
80
|
+
_composeViewDriverStream;
|
|
81
|
+
_xhrInterceptorStream;
|
|
82
|
+
_messageViewDriverStream;
|
|
83
|
+
_stopper = kefirStopper();
|
|
84
|
+
_navMarkerHiddenChanged = kefirBus();
|
|
85
|
+
_addonSidebarHiddenChanged = kefirBus();
|
|
86
|
+
_userInfo;
|
|
87
|
+
_timestampAccountSwitcherReady;
|
|
88
|
+
_timestampGlobalsFound;
|
|
89
|
+
_timestampOnready;
|
|
90
|
+
_lastCustomThreadListActivity;
|
|
91
|
+
_currentRouteViewDriver;
|
|
92
|
+
_appSidebarView = null;
|
|
93
|
+
getGmailThreadIdForRfcMessageId;
|
|
94
|
+
getRfcMessageIdForGmailThreadId;
|
|
95
|
+
getSyncThreadIdForOldGmailThreadId;
|
|
96
|
+
getOldGmailThreadIdFromSyncThreadId;
|
|
97
|
+
removeCachedOldGmailThreadIdFromSyncThreadId;
|
|
98
|
+
getGmailMessageIdForSyncDraftId;
|
|
99
|
+
getGmailMessageIdForSyncMessageId;
|
|
100
|
+
removeCachedGmailMessageIdForSyncMessageId;
|
|
101
|
+
constructor(appId, LOADER_VERSION, IMPL_VERSION, logger, opts, envData) {
|
|
102
|
+
customStyle();
|
|
103
|
+
this._appId = appId;
|
|
104
|
+
this._logger = logger;
|
|
105
|
+
this._opts = opts;
|
|
106
|
+
this._envData = envData;
|
|
107
|
+
this._page = makePageParserTree(this, document);
|
|
108
|
+
this._stopper.onValue(() => this._page.dump());
|
|
109
|
+
// Manages the mapping between RFC Message Ids and Gmail Message Ids. Caches to
|
|
110
|
+
// localStorage. Used for custom thread lists.
|
|
111
|
+
{
|
|
112
|
+
const rfcIdCache = new BiMapCache({
|
|
113
|
+
key: 'inboxsdk__cached_thread_ids',
|
|
114
|
+
getAfromB: (gmailThreadId) => getRfcMessageIdForGmailThreadId(this, gmailThreadId),
|
|
115
|
+
getBfromA: (rfcMessageId) => getGmailThreadIdForRfcMessageId(this, rfcMessageId),
|
|
116
|
+
});
|
|
117
|
+
this.getGmailThreadIdForRfcMessageId = (rfcMessageId) => rfcIdCache.getBfromA(rfcMessageId);
|
|
118
|
+
this.getRfcMessageIdForGmailThreadId = (gmailThreadId) => rfcIdCache.getAfromB(gmailThreadId);
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
getBfromA() {
|
|
140
|
-
throw new Error('should not happen');
|
|
120
|
+
// Manages mapping between old hex thread ids and new sync based thread ids
|
|
121
|
+
{
|
|
122
|
+
const syncThreadIdToOldGmailThreadIdCache = new BiMapCache({
|
|
123
|
+
key: 'inboxsdk__cached_sync_thread_id_old_gmail_thread_id',
|
|
124
|
+
getAfromB: (oldGmailThreadId) => {
|
|
125
|
+
return getSyncThreadForOldGmailThreadId(this, oldGmailThreadId).then(({ syncThreadID }) => syncThreadID);
|
|
126
|
+
},
|
|
127
|
+
getBfromA: (syncThreadID) => {
|
|
128
|
+
return getSyncThreadFromSyncThreadId(this, syncThreadID).then((syncThread) => {
|
|
129
|
+
if (syncThread)
|
|
130
|
+
return syncThread.oldGmailThreadID;
|
|
131
|
+
else
|
|
132
|
+
throw new Error('syncThread not found');
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
this.getSyncThreadIdForOldGmailThreadId = (oldGmailThreadId) => syncThreadIdToOldGmailThreadIdCache.getAfromB(oldGmailThreadId);
|
|
137
|
+
this.getOldGmailThreadIdFromSyncThreadId = (syncThreadId) => syncThreadIdToOldGmailThreadIdCache.getBfromA(syncThreadId);
|
|
138
|
+
this.removeCachedOldGmailThreadIdFromSyncThreadId = (syncThreadId) => syncThreadIdToOldGmailThreadIdCache.removeAfromCache(syncThreadId);
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// sent. It doesn't really need to be cached so it's not here.
|
|
149
|
-
this.getGmailMessageIdForSyncDraftId = syncDraftId => (0, _getGmailMessageIdForSyncMessageId.default)(this, syncDraftId);
|
|
150
|
-
}
|
|
151
|
-
this._gmailRouteProcessor = new _gmailRouteProcessor.default();
|
|
152
|
-
this._keyboardShortcutHelpModifier = new _keyboardShortcutHelpModifier.default();
|
|
153
|
-
this._butterBarDriver = new _gmailButterBarDriver.default();
|
|
154
|
-
_kefir.default.later(45 * 1000).takeUntilBy((0, _toItemWithLifetimeStream.default)(this._page.tree.getAllByTag('supportMenu'))).onValue(() => {
|
|
155
|
-
this._logger.errorSite(new Error('Failed to find gmail supportMenu'));
|
|
156
|
-
});
|
|
157
|
-
this._setupEventStreams();
|
|
158
|
-
this.onready.then(() => {
|
|
159
|
-
(0, _trackEvents.default)(this);
|
|
160
|
-
(0, _gmailLoadEvent.default)(this);
|
|
161
|
-
(0, _overrideGmailBackButton.default)(this, this._gmailRouteProcessor);
|
|
162
|
-
(0, _trackGmailStyles.default)();
|
|
163
|
-
(0, _temporaryTrackDownloadUrlValidity.default)(this);
|
|
164
|
-
if (opts.suppressAddonTitle != null) {
|
|
165
|
-
(0, _suppressAddon.default)(this, opts.suppressAddonTitle);
|
|
166
|
-
}
|
|
167
|
-
}).catch(err => {
|
|
168
|
-
this._logger.error(err);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
destroy() {
|
|
172
|
-
this._threadRowViewSelectionChanges.end();
|
|
173
|
-
this._keyboardShortcutHelpModifier.destroy();
|
|
174
|
-
this._stopper.destroy();
|
|
175
|
-
(0, _gmailThreadRowView.removeAllThreadRowUnclaimedModifications)();
|
|
176
|
-
}
|
|
177
|
-
getAppId() {
|
|
178
|
-
return this._appId;
|
|
179
|
-
}
|
|
180
|
-
getOpts() {
|
|
181
|
-
return this._opts;
|
|
182
|
-
}
|
|
183
|
-
getPageCommunicator() {
|
|
184
|
-
return this._pageCommunicator;
|
|
185
|
-
}
|
|
186
|
-
getPageCommunicatorPromise() {
|
|
187
|
-
return this._pageCommunicatorPromise;
|
|
188
|
-
}
|
|
189
|
-
getLogger() {
|
|
190
|
-
return this._logger;
|
|
191
|
-
}
|
|
192
|
-
getTagTree() {
|
|
193
|
-
return this._page.tree;
|
|
194
|
-
}
|
|
195
|
-
getCustomListSearchStringsToRouteIds() {
|
|
196
|
-
return this._customListSearchStringsToRouteIds;
|
|
197
|
-
}
|
|
198
|
-
getThreadRowIdentifier() {
|
|
199
|
-
return this._threadRowIdentifier;
|
|
200
|
-
}
|
|
201
|
-
getButterBarDriver() {
|
|
202
|
-
return this._butterBarDriver;
|
|
203
|
-
}
|
|
204
|
-
getButterBar() {
|
|
205
|
-
return this._butterBar;
|
|
206
|
-
}
|
|
207
|
-
setButterBar(bb) {
|
|
208
|
-
this._butterBar = bb;
|
|
209
|
-
}
|
|
210
|
-
getCustomRouteIDs() {
|
|
211
|
-
return this._customRouteIDs;
|
|
212
|
-
}
|
|
213
|
-
getCustomListRouteIDs() {
|
|
214
|
-
return this._customListRouteIDs;
|
|
215
|
-
}
|
|
216
|
-
getKeyboardShortcutHelpModifier() {
|
|
217
|
-
return this._keyboardShortcutHelpModifier;
|
|
218
|
-
}
|
|
219
|
-
getRouteViewDriverStream() {
|
|
220
|
-
return this._routeViewDriverStream;
|
|
221
|
-
}
|
|
222
|
-
getRowListViewDriverStream() {
|
|
223
|
-
return this._rowListViewDriverStream;
|
|
224
|
-
}
|
|
225
|
-
getThreadRowViewDriverStream() {
|
|
226
|
-
return this._threadRowViewDriverKefirStream;
|
|
227
|
-
}
|
|
228
|
-
getThreadViewDriverStream() {
|
|
229
|
-
return (0, _toItemWithLifetimeStream.default)(this._threadViewDriverLiveSet).map(_ref2 => {
|
|
230
|
-
let {
|
|
231
|
-
el
|
|
232
|
-
} = _ref2;
|
|
233
|
-
return el;
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
getAttachmentCardViewDriverStream() {
|
|
237
|
-
return this._messageViewDriverStream.flatMap(messageViewDriver => messageViewDriver.isLoaded() ? _kefir.default.constant(messageViewDriver) : messageViewDriver.getEventStream().filter(event => event.eventName === 'messageLoad').map(() => messageViewDriver).take(1)).map(messageView => messageView.getAttachmentCardViewDrivers()).flatten();
|
|
238
|
-
}
|
|
239
|
-
getComposeViewDriverStream() {
|
|
240
|
-
return this._composeViewDriverStream;
|
|
241
|
-
}
|
|
242
|
-
getXhrInterceptorStream() {
|
|
243
|
-
return this._xhrInterceptorStream;
|
|
244
|
-
}
|
|
245
|
-
getMessageViewDriverStream() {
|
|
246
|
-
return this._messageViewDriverStream;
|
|
247
|
-
}
|
|
248
|
-
getStopper() {
|
|
249
|
-
return this._stopper;
|
|
250
|
-
}
|
|
251
|
-
getEnvData() {
|
|
252
|
-
return this._envData;
|
|
253
|
-
}
|
|
254
|
-
getTimestampOnReady() {
|
|
255
|
-
if (this._timestampOnready == null) {
|
|
256
|
-
this._logger.error(new Error('getTimestampOnReady called before ready'));
|
|
257
|
-
return Date.now();
|
|
258
|
-
}
|
|
259
|
-
return this._timestampOnready;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Returns a stream that emits an event once at least `time` milliseconds has
|
|
263
|
-
// passed since the GmailDriver's ready event.
|
|
264
|
-
delayToTimeAfterReady(time) {
|
|
265
|
-
const targetTime = this.getTimestampOnReady() + time;
|
|
266
|
-
const timeToWait = Math.max(0, targetTime - Date.now());
|
|
267
|
-
return _kefir.default.later(timeToWait);
|
|
268
|
-
}
|
|
269
|
-
getTimings() {
|
|
270
|
-
return {
|
|
271
|
-
piMainStarted: this._envData.piMainStarted,
|
|
272
|
-
piLoadStarted: this._envData.piLoadStarted,
|
|
273
|
-
globalsFound: this._timestampGlobalsFound,
|
|
274
|
-
accountSwitcherReady: this._timestampAccountSwitcherReady,
|
|
275
|
-
onready: this._timestampOnready
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
registerThreadButton(options) {
|
|
279
|
-
const unregister = (0, _kefirStopper.default)();
|
|
280
|
-
const removeButtonOnUnregister = button => {
|
|
281
|
-
unregister.takeUntilBy(button.getStopper()).onValue(() => {
|
|
282
|
-
button.destroy();
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
const toolbarViewSub = (0, _toValueObservable.default)(this._toolbarViewDriverLiveSet).subscribe(_ref3 => {
|
|
286
|
-
let {
|
|
287
|
-
value: gmailToolbarView
|
|
288
|
-
} = _ref3;
|
|
289
|
-
if (gmailToolbarView.isForThread()) {
|
|
290
|
-
if (!options.positions || (0, _includes.default)(options.positions, 'THREAD')) {
|
|
291
|
-
removeButtonOnUnregister(gmailToolbarView.addButton({
|
|
292
|
-
...options,
|
|
293
|
-
section: options.threadSection || 'METADATA_STATE',
|
|
294
|
-
onClick: event => {
|
|
295
|
-
options.onClick({
|
|
296
|
-
position: 'THREAD',
|
|
297
|
-
dropdown: event.dropdown,
|
|
298
|
-
selectedThreadViewDrivers: [gmailToolbarView.getThreadViewDriver()],
|
|
299
|
-
selectedThreadRowViewDrivers: []
|
|
300
|
-
});
|
|
140
|
+
// mapping between sync message ids and old message ids
|
|
141
|
+
{
|
|
142
|
+
try {
|
|
143
|
+
// TODO remove sometime after March 24 2019 to give time for this to
|
|
144
|
+
// run for most users.
|
|
145
|
+
localStorage.removeItem('inboxsdk__cached_gmail_and_inbox_message_ids_2');
|
|
301
146
|
}
|
|
302
|
-
|
|
147
|
+
catch (err) {
|
|
148
|
+
// eslint-disable-next-line no-console
|
|
149
|
+
console.error(err);
|
|
150
|
+
}
|
|
151
|
+
const gmailMessageIdForSyncMessageIdCache = new BiMapCache({
|
|
152
|
+
key: 'inboxsdk__cached_gmail_and_inbox_message_ids_3',
|
|
153
|
+
getAfromB: (sync) => getGmailMessageIdForSyncMessageId(this, sync),
|
|
154
|
+
getBfromA() {
|
|
155
|
+
throw new Error('should not happen');
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
this.getGmailMessageIdForSyncMessageId = (syncMessageId) => gmailMessageIdForSyncMessageIdCache.getAfromB(syncMessageId);
|
|
159
|
+
this.removeCachedGmailMessageIdForSyncMessageId = (syncMessageId) => gmailMessageIdForSyncMessageIdCache.removeBfromCache(syncMessageId);
|
|
160
|
+
// It's important that this doesn't use the same cache for looking up
|
|
161
|
+
// sync message IDs, because the legacy ID of a draft changes when it's
|
|
162
|
+
// sent. It doesn't really need to be cached so it's not here.
|
|
163
|
+
this.getGmailMessageIdForSyncDraftId = (syncDraftId) => getGmailMessageIdForSyncMessageId(this, syncDraftId);
|
|
303
164
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
165
|
+
this._gmailRouteProcessor = new GmailRouteProcessor();
|
|
166
|
+
this._keyboardShortcutHelpModifier = new KeyboardShortcutHelpModifier();
|
|
167
|
+
this._butterBarDriver = new GmailButterBarDriver();
|
|
168
|
+
Kefir.later(45 * 1000, undefined)
|
|
169
|
+
.takeUntilBy(toItemWithLifetimeStream(this._page.tree.getAllByTag('supportMenu')))
|
|
170
|
+
.onValue(() => {
|
|
171
|
+
this._logger.errorSite(new Error('Failed to find gmail supportMenu'));
|
|
172
|
+
});
|
|
173
|
+
this._setupEventStreams();
|
|
174
|
+
this.onready
|
|
175
|
+
.then(() => {
|
|
176
|
+
trackEvents(this);
|
|
177
|
+
gmailLoadEvent(this);
|
|
178
|
+
overrideGmailBackButton(this, this._gmailRouteProcessor);
|
|
179
|
+
trackGmailStyles();
|
|
180
|
+
temporaryTrackDownloadUrlValidity(this);
|
|
181
|
+
if (opts.suppressAddonTitle != null) {
|
|
182
|
+
suppressAddon(this, opts.suppressAddonTitle);
|
|
317
183
|
}
|
|
318
|
-
|
|
184
|
+
})
|
|
185
|
+
.catch((err) => {
|
|
186
|
+
this._logger.error(err);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
destroy() {
|
|
190
|
+
this._threadRowViewSelectionChanges.end();
|
|
191
|
+
this._keyboardShortcutHelpModifier.destroy();
|
|
192
|
+
this._stopper.destroy();
|
|
193
|
+
removeAllThreadRowUnclaimedModifications();
|
|
194
|
+
}
|
|
195
|
+
getAppId() {
|
|
196
|
+
return this._appId;
|
|
197
|
+
}
|
|
198
|
+
getOpts() {
|
|
199
|
+
return this._opts;
|
|
200
|
+
}
|
|
201
|
+
getPageCommunicator() {
|
|
202
|
+
return this._pageCommunicator;
|
|
203
|
+
}
|
|
204
|
+
getPageCommunicatorPromise() {
|
|
205
|
+
return this._pageCommunicatorPromise;
|
|
206
|
+
}
|
|
207
|
+
getLogger() {
|
|
208
|
+
return this._logger;
|
|
209
|
+
}
|
|
210
|
+
getTagTree() {
|
|
211
|
+
return this._page.tree;
|
|
212
|
+
}
|
|
213
|
+
getCustomListSearchStringsToRouteIds() {
|
|
214
|
+
return this._customListSearchStringsToRouteIds;
|
|
215
|
+
}
|
|
216
|
+
getThreadRowIdentifier() {
|
|
217
|
+
return this._threadRowIdentifier;
|
|
218
|
+
}
|
|
219
|
+
getButterBarDriver() {
|
|
220
|
+
return this._butterBarDriver;
|
|
221
|
+
}
|
|
222
|
+
getButterBar() {
|
|
223
|
+
return this._butterBar;
|
|
224
|
+
}
|
|
225
|
+
setButterBar(bb) {
|
|
226
|
+
this._butterBar = bb;
|
|
227
|
+
}
|
|
228
|
+
getCustomRouteIDs() {
|
|
229
|
+
return this._customRouteIDs;
|
|
230
|
+
}
|
|
231
|
+
getCustomListRouteIDs() {
|
|
232
|
+
return this._customListRouteIDs;
|
|
233
|
+
}
|
|
234
|
+
getKeyboardShortcutHelpModifier() {
|
|
235
|
+
return this._keyboardShortcutHelpModifier;
|
|
236
|
+
}
|
|
237
|
+
getRouteViewDriverStream() {
|
|
238
|
+
return this._routeViewDriverStream;
|
|
239
|
+
}
|
|
240
|
+
getRowListViewDriverStream() {
|
|
241
|
+
return this._rowListViewDriverStream;
|
|
242
|
+
}
|
|
243
|
+
getThreadRowViewDriverStream() {
|
|
244
|
+
return this._threadRowViewDriverKefirStream;
|
|
245
|
+
}
|
|
246
|
+
getThreadViewDriverStream() {
|
|
247
|
+
return toItemWithLifetimeStream(this._threadViewDriverLiveSet).map(({ el }) => el);
|
|
248
|
+
}
|
|
249
|
+
getAttachmentCardViewDriverStream() {
|
|
250
|
+
return this._messageViewDriverStream
|
|
251
|
+
.flatMap((messageViewDriver) => messageViewDriver.isLoaded()
|
|
252
|
+
? Kefir.constant(messageViewDriver)
|
|
253
|
+
: messageViewDriver
|
|
254
|
+
.getEventStream()
|
|
255
|
+
.filter((event) => event.eventName === 'messageLoad')
|
|
256
|
+
.map(() => messageViewDriver)
|
|
257
|
+
.take(1))
|
|
258
|
+
.map((messageView) => messageView.getAttachmentCardViewDrivers())
|
|
259
|
+
.flatten();
|
|
260
|
+
}
|
|
261
|
+
getComposeViewDriverStream() {
|
|
262
|
+
return this._composeViewDriverStream;
|
|
263
|
+
}
|
|
264
|
+
getXhrInterceptorStream() {
|
|
265
|
+
return this._xhrInterceptorStream;
|
|
266
|
+
}
|
|
267
|
+
getMessageViewDriverStream() {
|
|
268
|
+
return this._messageViewDriverStream;
|
|
269
|
+
}
|
|
270
|
+
getStopper() {
|
|
271
|
+
return this._stopper;
|
|
272
|
+
}
|
|
273
|
+
getEnvData() {
|
|
274
|
+
return this._envData;
|
|
275
|
+
}
|
|
276
|
+
getTimestampOnReady() {
|
|
277
|
+
if (this._timestampOnready == null) {
|
|
278
|
+
this._logger.error(new Error('getTimestampOnReady called before ready'));
|
|
279
|
+
return Date.now();
|
|
319
280
|
}
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
281
|
+
return this._timestampOnready;
|
|
282
|
+
}
|
|
283
|
+
// Returns a stream that emits an event once at least `time` milliseconds has
|
|
284
|
+
// passed since the GmailDriver's ready event.
|
|
285
|
+
delayToTimeAfterReady(time) {
|
|
286
|
+
const targetTime = this.getTimestampOnReady() + time;
|
|
287
|
+
const timeToWait = Math.max(0, targetTime - Date.now());
|
|
288
|
+
return Kefir.later(timeToWait, undefined);
|
|
289
|
+
}
|
|
290
|
+
getTimings() {
|
|
291
|
+
return {
|
|
292
|
+
piMainStarted: this._envData.piMainStarted,
|
|
293
|
+
piLoadStarted: this._envData.piLoadStarted,
|
|
294
|
+
globalsFound: this._timestampGlobalsFound,
|
|
295
|
+
accountSwitcherReady: this._timestampAccountSwitcherReady,
|
|
296
|
+
onready: this._timestampOnready,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
registerThreadButton(options) {
|
|
300
|
+
const unregister = kefirStopper();
|
|
301
|
+
const removeButtonOnUnregister = (button) => {
|
|
302
|
+
unregister.takeUntilBy(button.getStopper()).onValue(() => {
|
|
303
|
+
button.destroy();
|
|
339
304
|
});
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
305
|
+
};
|
|
306
|
+
const toolbarViewSub = toValueObservable(this._toolbarViewDriverLiveSet).subscribe(({ value: gmailToolbarView }) => {
|
|
307
|
+
if (gmailToolbarView.isForThread()) {
|
|
308
|
+
if (!options.positions || includes(options.positions, 'THREAD')) {
|
|
309
|
+
removeButtonOnUnregister(gmailToolbarView.addButton({
|
|
310
|
+
...options,
|
|
311
|
+
section: options.threadSection || 'METADATA_STATE',
|
|
312
|
+
onClick: (event) => {
|
|
313
|
+
options.onClick({
|
|
314
|
+
position: 'THREAD',
|
|
315
|
+
dropdown: event.dropdown,
|
|
316
|
+
selectedThreadViewDrivers: [
|
|
317
|
+
gmailToolbarView.getThreadViewDriver(),
|
|
318
|
+
],
|
|
319
|
+
selectedThreadRowViewDrivers: [],
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if (gmailToolbarView.isForRowList()) {
|
|
326
|
+
if (!options.positions || includes(options.positions, 'LIST')) {
|
|
327
|
+
removeButtonOnUnregister(gmailToolbarView.addButton({
|
|
328
|
+
...options,
|
|
329
|
+
section: options.listSection || 'METADATA_STATE',
|
|
330
|
+
onClick: (event) => {
|
|
331
|
+
const selectedThreadRowViewDrivers = Array.from(gmailToolbarView.getThreadRowViewDrivers()).filter((gmailThreadRow) => gmailThreadRow.isSelected());
|
|
332
|
+
options.onClick({
|
|
333
|
+
position: 'LIST',
|
|
334
|
+
dropdown: event.dropdown,
|
|
335
|
+
selectedThreadViewDrivers: [],
|
|
336
|
+
selectedThreadRowViewDrivers,
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
unregister.onValue(() => {
|
|
344
|
+
toolbarViewSub.unsubscribe();
|
|
345
|
+
});
|
|
346
|
+
if (!options.positions || includes(options.positions, 'ROW')) {
|
|
347
|
+
const perThreadRow = (gmailThreadRow) => {
|
|
348
|
+
gmailThreadRow.addButton(Kefir.constant({
|
|
349
|
+
hasDropdown: options.hasDropdown,
|
|
350
|
+
iconClass: options.iconClass,
|
|
351
|
+
iconUrl: options.iconUrl,
|
|
352
|
+
orderHint: options.orderHint,
|
|
353
|
+
onClick: (event) => {
|
|
354
|
+
if (!options.onClick)
|
|
355
|
+
return;
|
|
356
|
+
options.onClick({
|
|
357
|
+
position: 'ROW',
|
|
358
|
+
dropdown: event.dropdown,
|
|
359
|
+
selectedThreadViewDrivers: [],
|
|
360
|
+
selectedThreadRowViewDrivers: [gmailThreadRow],
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
}).merge(unregister));
|
|
364
|
+
};
|
|
365
|
+
if (this._currentRouteViewDriver) {
|
|
366
|
+
this._currentRouteViewDriver
|
|
367
|
+
.getRowListViews()
|
|
368
|
+
.forEach((gmailRowListView) => {
|
|
369
|
+
gmailRowListView.getThreadRowViewDrivers().forEach(perThreadRow);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
const threadRowViewSub = this._threadRowViewDriverKefirStream.observe({
|
|
373
|
+
value: perThreadRow,
|
|
374
|
+
});
|
|
375
|
+
unregister.onValue(() => {
|
|
376
|
+
threadRowViewSub.unsubscribe();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return () => {
|
|
380
|
+
unregister.destroy();
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
hashChangeNoViewChange(hash) {
|
|
384
|
+
if (hash[0] !== '#') {
|
|
385
|
+
throw new Error('bad hash');
|
|
386
|
+
}
|
|
387
|
+
window.history.replaceState(null, null, hash);
|
|
388
|
+
var hce = new window.HashChangeEvent('hashchange', {
|
|
389
|
+
oldURL: document.location.href.replace(/#.*$/, '') + '#inboxsdk-fake-no-vc',
|
|
390
|
+
newURL: document.location.href.replace(/#.*$/, '') + hash,
|
|
346
391
|
});
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
392
|
+
window.dispatchEvent(hce);
|
|
393
|
+
}
|
|
394
|
+
addCustomRouteID(routeID) {
|
|
395
|
+
this._customRouteIDs.add(routeID);
|
|
396
|
+
this._pageCommunicator.registerAllowedHashLinkStartTerm(routeID.split('/')[0]);
|
|
397
|
+
return () => {
|
|
398
|
+
this._customRouteIDs.delete(routeID);
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
addCustomListRouteID(routeID, handler) {
|
|
402
|
+
this._customListRouteIDs.set(routeID, handler);
|
|
403
|
+
this._pageCommunicator.registerAllowedHashLinkStartTerm(routeID.split('/')[0]);
|
|
404
|
+
return () => {
|
|
405
|
+
this._customListRouteIDs.delete(routeID);
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
signalCustomThreadListActivity(customRouteID) {
|
|
409
|
+
this._lastCustomThreadListActivity = {
|
|
410
|
+
customRouteID,
|
|
411
|
+
timestamp: new Date(),
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
// Returns the last time a request for a custom thread list search has gone
|
|
415
|
+
// out or we got a response, and the customRouteID for that.
|
|
416
|
+
getLastCustomThreadListActivity() {
|
|
417
|
+
return this._lastCustomThreadListActivity;
|
|
418
|
+
}
|
|
419
|
+
showCustomThreadList(customRouteID, onActivate, params) {
|
|
420
|
+
showCustomThreadList(this, customRouteID, onActivate, params);
|
|
421
|
+
}
|
|
422
|
+
showCustomRouteView(element) {
|
|
423
|
+
showCustomRouteView(this, element);
|
|
424
|
+
}
|
|
425
|
+
showNativeRouteView() {
|
|
426
|
+
showNativeRouteView(this);
|
|
427
|
+
}
|
|
428
|
+
createLink(routeID, params) {
|
|
429
|
+
return createLink(this._gmailRouteProcessor, routeID, params);
|
|
430
|
+
}
|
|
431
|
+
goto(routeID, params) {
|
|
432
|
+
return gotoView(this, routeID, params);
|
|
433
|
+
}
|
|
434
|
+
resolveUrlRedirects(url) {
|
|
435
|
+
return this._pageCommunicatorPromise.then((pageCommunicator) => pageCommunicator.resolveUrlRedirects(url));
|
|
436
|
+
}
|
|
437
|
+
registerSearchSuggestionsProvider(handler) {
|
|
438
|
+
registerSearchSuggestionsProvider(this, handler);
|
|
439
|
+
}
|
|
440
|
+
registerSearchQueryRewriter(obj) {
|
|
441
|
+
registerSearchQueryRewriter(this._pageCommunicator, obj);
|
|
442
|
+
}
|
|
443
|
+
addToolbarButtonForApp(buttonDescriptor) {
|
|
444
|
+
return addToolbarButtonForApp(this, buttonDescriptor);
|
|
445
|
+
}
|
|
446
|
+
async openNewComposeViewDriver() {
|
|
447
|
+
try {
|
|
448
|
+
const composeViewDriverPromise = this.getNextComposeViewDriver();
|
|
449
|
+
await openComposeWindow(this);
|
|
450
|
+
const composeViewDriver = await composeViewDriverPromise;
|
|
451
|
+
return composeViewDriver;
|
|
452
|
+
}
|
|
453
|
+
catch (err) {
|
|
454
|
+
this._logger.error(err);
|
|
455
|
+
throw err;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
getNextComposeViewDriver(timeout = 10 * 1000) {
|
|
459
|
+
return this._composeViewDriverStream
|
|
460
|
+
.merge(Kefir.later(timeout, new Error('Reached timeout while waiting for getNextComposeViewDriver')))
|
|
461
|
+
.beforeEnd(() => new Error('Driver was shut down before a new compose was found'))
|
|
462
|
+
.flatMap((x) => x instanceof Error ? Kefir.constantError(x) : Kefir.constant(x))
|
|
463
|
+
.take(1)
|
|
464
|
+
.takeErrors(1)
|
|
465
|
+
.toPromise();
|
|
466
|
+
}
|
|
467
|
+
openDraftByMessageID(messageID) {
|
|
468
|
+
return openDraftByMessageID(this, messageID);
|
|
469
|
+
}
|
|
470
|
+
createModalViewDriver(options) {
|
|
471
|
+
return new GmailModalViewDriver(options);
|
|
472
|
+
}
|
|
473
|
+
createMoleViewDriver(options) {
|
|
474
|
+
return new GmailMoleViewDriver(this, options);
|
|
475
|
+
}
|
|
476
|
+
createDrawerViewDriver(options) {
|
|
477
|
+
return new InboxDrawerView(options);
|
|
478
|
+
}
|
|
479
|
+
createBackdrop(zIndex, target) {
|
|
480
|
+
return new GmailBackdrop(zIndex, target);
|
|
481
|
+
}
|
|
482
|
+
addNavItem(appId, navItemDescriptorPropertyStream, navMenuInjectionContainer) {
|
|
483
|
+
return addNavItem(this, appId, navItemDescriptorPropertyStream, navMenuInjectionContainer);
|
|
484
|
+
}
|
|
485
|
+
addAppMenuItem(menuItemDescriptor) {
|
|
486
|
+
return addAppMenuItem(this, menuItemDescriptor);
|
|
487
|
+
}
|
|
488
|
+
addSupportItem(supportItemDescriptor) {
|
|
489
|
+
return addSupportItem(this, supportItemDescriptor);
|
|
490
|
+
}
|
|
491
|
+
getSentMailNativeNavItem() {
|
|
492
|
+
const p = getNativeNavItem(this, 'sent');
|
|
493
|
+
p.catch((err) => this._logger.error(err));
|
|
494
|
+
return p;
|
|
495
|
+
}
|
|
496
|
+
setShowNativeNavMarker(isNative) {
|
|
497
|
+
this._navMarkerHiddenChanged.emit(null);
|
|
498
|
+
const leftNavContainerElement = GmailElementGetter.getLeftNavContainerElement();
|
|
499
|
+
if (leftNavContainerElement) {
|
|
500
|
+
if (isNative) {
|
|
501
|
+
leftNavContainerElement.classList.remove('inboxsdk__hide_native_marker');
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
leftNavContainerElement.classList.add('inboxsdk__hide_native_marker');
|
|
505
|
+
this._stopper.takeUntilBy(this._navMarkerHiddenChanged).onValue(() => {
|
|
506
|
+
leftNavContainerElement.classList.remove('inboxsdk__hide_native_marker');
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
setShowNativeAddonSidebar(isNative) {
|
|
512
|
+
this._addonSidebarHiddenChanged.emit(null);
|
|
513
|
+
const addonContainerElement = GmailElementGetter.getAddonSidebarContainerElement();
|
|
514
|
+
const mainContentBodyContainerElement = GmailElementGetter.getMainContentBodyContainerElement();
|
|
515
|
+
if (addonContainerElement && mainContentBodyContainerElement) {
|
|
516
|
+
const parent = mainContentBodyContainerElement.parentElement;
|
|
517
|
+
if (!parent)
|
|
518
|
+
return;
|
|
519
|
+
if (isNative) {
|
|
520
|
+
parent.classList.remove('inboxsdk__hide_addon_container');
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
parent.classList.add('inboxsdk__hide_addon_container');
|
|
524
|
+
this._stopper
|
|
525
|
+
.takeUntilBy(this._addonSidebarHiddenChanged)
|
|
526
|
+
.onValue(() => {
|
|
527
|
+
parent.classList.remove('inboxsdk__hide_addon_container');
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async getGmailActionToken() {
|
|
533
|
+
return this._pageCommunicator.getActionTokenValue();
|
|
534
|
+
}
|
|
535
|
+
getUserEmailAddress() {
|
|
536
|
+
return this._pageCommunicator.getUserEmailAddress();
|
|
537
|
+
}
|
|
538
|
+
isConversationViewDisabled() {
|
|
539
|
+
return this._pageCommunicator.isConversationViewDisabled();
|
|
540
|
+
}
|
|
541
|
+
getUserLanguage() {
|
|
542
|
+
return this._pageCommunicator.getUserLanguage();
|
|
543
|
+
}
|
|
544
|
+
getUserContact() {
|
|
545
|
+
return {
|
|
546
|
+
emailAddress: this.getUserEmailAddress(),
|
|
547
|
+
name: this._userInfo.getUserName(),
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
getAccountSwitcherContactList() {
|
|
551
|
+
return this._userInfo.getAccountSwitcherContactList();
|
|
552
|
+
}
|
|
553
|
+
activateShortcut(keyboardShortcutHandle, appName, appIconUrl) {
|
|
554
|
+
this.getKeyboardShortcutHelpModifier().set(keyboardShortcutHandle, this._appId, appName, appIconUrl);
|
|
555
|
+
keyboardShortcutHandle.once('destroy', () => {
|
|
556
|
+
this.getKeyboardShortcutHelpModifier().delete(keyboardShortcutHandle);
|
|
477
557
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
558
|
+
}
|
|
559
|
+
_setupEventStreams() {
|
|
560
|
+
var result = makeXhrInterceptor();
|
|
561
|
+
this._xhrInterceptorStream = result.xhrInterceptStream.takeUntilBy(this._stopper);
|
|
562
|
+
this._pageCommunicatorPromise = result.pageCommunicatorPromise;
|
|
563
|
+
this.onready = this._pageCommunicatorPromise.then((pageCommunicator) => {
|
|
564
|
+
this._timestampGlobalsFound = Date.now();
|
|
565
|
+
this._pageCommunicator = pageCommunicator;
|
|
566
|
+
this._logger.setUserEmailAddress(this.getUserEmailAddress());
|
|
567
|
+
this._logger.setIsUsingSyncAPI(pageCommunicator.isUsingSyncAPI());
|
|
568
|
+
this._userInfo = new UserInfo(this);
|
|
569
|
+
this._timestampAccountSwitcherReady = Date.now();
|
|
570
|
+
this._routeViewDriverStream = setupRouteViewDriverStream(this._gmailRouteProcessor, this)
|
|
571
|
+
.takeUntilBy(this._stopper)
|
|
572
|
+
.toProperty();
|
|
573
|
+
this._routeViewDriverStream.onValue((gmailRouteView) => {
|
|
574
|
+
this._currentRouteViewDriver = gmailRouteView;
|
|
575
|
+
});
|
|
576
|
+
this._rowListViewDriverStream = this._setupRouteSubViewDriver('newGmailRowListView').takeUntilBy(this._stopper);
|
|
577
|
+
this._setupThreadRowViewDriverKefirStream();
|
|
578
|
+
this._threadViewDriverLiveSet = toLiveSet(this._setupRouteSubViewDriver('newGmailThreadView')
|
|
579
|
+
.takeUntilBy(this._stopper)
|
|
580
|
+
.flatMap((gmailThreadView) => gmailThreadView.getReadyStream().map(() => gmailThreadView))
|
|
581
|
+
.map((gmailThreadView) => ({
|
|
582
|
+
el: gmailThreadView,
|
|
583
|
+
removalStream: gmailThreadView.getStopper(),
|
|
584
|
+
})));
|
|
585
|
+
this._setupToolbarViewDriverStream();
|
|
586
|
+
this._setupMessageViewDriverStream();
|
|
587
|
+
this._setupComposeViewDriverStream();
|
|
588
|
+
this._threadRowIdentifier = new ThreadRowIdentifier(this);
|
|
589
|
+
this._timestampOnready = Date.now();
|
|
494
590
|
});
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return this._pageCommunicator.isConversationViewDisabled();
|
|
506
|
-
}
|
|
507
|
-
getUserLanguage() {
|
|
508
|
-
return this._pageCommunicator.getUserLanguage();
|
|
509
|
-
}
|
|
510
|
-
getUserContact() {
|
|
511
|
-
return {
|
|
512
|
-
emailAddress: this.getUserEmailAddress(),
|
|
513
|
-
name: this._userInfo.getUserName()
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
getAccountSwitcherContactList() {
|
|
517
|
-
return this._userInfo.getAccountSwitcherContactList();
|
|
518
|
-
}
|
|
519
|
-
activateShortcut(keyboardShortcutHandle, appName, appIconUrl) {
|
|
520
|
-
this.getKeyboardShortcutHelpModifier().set(keyboardShortcutHandle, this._appId, appName, appIconUrl);
|
|
521
|
-
keyboardShortcutHandle.once('destroy', () => {
|
|
522
|
-
this.getKeyboardShortcutHelpModifier().delete(keyboardShortcutHandle);
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
_setupEventStreams() {
|
|
526
|
-
var result = (0, _makeXhrInterceptor.default)();
|
|
527
|
-
this._xhrInterceptorStream = result.xhrInterceptStream.takeUntilBy(this._stopper);
|
|
528
|
-
this._pageCommunicatorPromise = result.pageCommunicatorPromise;
|
|
529
|
-
this.onready = this._pageCommunicatorPromise.then(pageCommunicator => {
|
|
530
|
-
this._timestampGlobalsFound = Date.now();
|
|
531
|
-
this._pageCommunicator = pageCommunicator;
|
|
532
|
-
this._logger.setUserEmailAddress(this.getUserEmailAddress());
|
|
533
|
-
this._logger.setIsUsingSyncAPI(pageCommunicator.isUsingSyncAPI());
|
|
534
|
-
this._userInfo = new _userInfo.default(this);
|
|
535
|
-
this._timestampAccountSwitcherReady = Date.now();
|
|
536
|
-
this._routeViewDriverStream = (0, _setupRouteViewDriverStream.default)(this._gmailRouteProcessor, this).takeUntilBy(this._stopper).toProperty();
|
|
537
|
-
this._routeViewDriverStream.onValue(gmailRouteView => {
|
|
538
|
-
this._currentRouteViewDriver = gmailRouteView;
|
|
539
|
-
});
|
|
540
|
-
this._rowListViewDriverStream = this._setupRouteSubViewDriver('newGmailRowListView').takeUntilBy(this._stopper);
|
|
541
|
-
this._setupThreadRowViewDriverKefirStream();
|
|
542
|
-
this._threadViewDriverLiveSet = (0, _toLiveSet.default)(this._setupRouteSubViewDriver('newGmailThreadView').takeUntilBy(this._stopper).flatMap(gmailThreadView => gmailThreadView.getReadyStream().map(() => gmailThreadView)).map(gmailThreadView => ({
|
|
543
|
-
el: gmailThreadView,
|
|
544
|
-
removalStream: gmailThreadView.getStopper()
|
|
545
|
-
})));
|
|
546
|
-
this._setupToolbarViewDriverStream();
|
|
547
|
-
this._setupMessageViewDriverStream();
|
|
548
|
-
this._setupComposeViewDriverStream();
|
|
549
|
-
this._threadRowIdentifier = new _threadRowIdentifier.default(this);
|
|
550
|
-
this._timestampOnready = Date.now();
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
_setupComposeViewDriverStream() {
|
|
554
|
-
this._composeViewDriverStream = (0, _setupComposeViewDriverStream.default)(this, this._messageViewDriverStream, this._xhrInterceptorStream).takeUntilBy(this._stopper);
|
|
555
|
-
}
|
|
556
|
-
_setupRouteSubViewDriver(viewName) {
|
|
557
|
-
return this._routeViewDriverStream.flatMap(gmailRouteView => {
|
|
558
|
-
return gmailRouteView.getEventStream().filter(event => event.eventName === viewName).map(event => event.view);
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
_setupThreadRowViewDriverKefirStream() {
|
|
562
|
-
this._threadRowViewDriverKefirStream = this._rowListViewDriverStream.flatMap(rowListViewDriver => rowListViewDriver.getRowViewDriverStream()).takeUntilBy(this._stopper);
|
|
563
|
-
}
|
|
564
|
-
_setupToolbarViewDriverStream() {
|
|
565
|
-
this._toolbarViewDriverLiveSet = (0, _toLiveSet.default)(_kefir.default.merge([this._rowListViewDriverStream.map(gmailRowListView => gmailRowListView.getToolbarView()), this.getThreadViewDriverStream().map(gmailThreadView => gmailThreadView.getToolbarView())]).filter(Boolean).flatMap(gmailToolbarView => gmailToolbarView.waitForReady()).map(gmailToolbarView => ({
|
|
566
|
-
el: gmailToolbarView,
|
|
567
|
-
removalStream: gmailToolbarView.getStopper()
|
|
568
|
-
})).takeUntilBy(this._stopper));
|
|
569
|
-
this._toolbarViewDriverLiveSet.subscribe({});
|
|
570
|
-
}
|
|
571
|
-
_setupMessageViewDriverStream() {
|
|
572
|
-
this._messageViewDriverStream = this.getThreadViewDriverStream().flatMap(gmailThreadView => gmailThreadView.getMessageViewDriverStream()).takeUntilBy(this._stopper);
|
|
573
|
-
}
|
|
574
|
-
async addGlobalSidebarContentPanel(descriptor) {
|
|
575
|
-
await this.waitForGlobalSidebarReady().merge(this._stopper.flatMap(() => _kefir.default.constantError(new Error('Driver instance was destroyed early')))).take(1).takeErrors(1).toPromise();
|
|
576
|
-
const appSidebar = this.getGlobalSidebar();
|
|
577
|
-
return appSidebar.addGlobalSidebarContentPanel(descriptor);
|
|
578
|
-
}
|
|
579
|
-
waitForGlobalSidebarReady() {
|
|
580
|
-
const condition = () => _gmailElementGetter.default.getCompanionSidebarContentContainerElement() && (_gmailElementGetter.default.getCompanionSidebarIconContainerElement() || _gmailElementGetter.default.getAddonSidebarContainerElement());
|
|
581
|
-
if (condition()) {
|
|
582
|
-
return _kefir.default.constant(undefined);
|
|
583
|
-
}
|
|
584
|
-
return (0, _streamWaitFor.default)(condition).map(() => undefined);
|
|
585
|
-
}
|
|
586
|
-
getGlobalSidebar() {
|
|
587
|
-
let appSidebarView = this._appSidebarView;
|
|
588
|
-
if (!appSidebarView) {
|
|
589
|
-
const companionSidebarContentContainerEl = _gmailElementGetter.default.getCompanionSidebarContentContainerElement();
|
|
590
|
-
if (!companionSidebarContentContainerEl) throw new Error('did not find companionSidebarContentContainerEl');
|
|
591
|
-
appSidebarView = this._appSidebarView = new _gmailAppSidebarView.default(this, companionSidebarContentContainerEl);
|
|
592
|
-
}
|
|
593
|
-
return appSidebarView;
|
|
594
|
-
}
|
|
595
|
-
isRunningInPageContext() {
|
|
596
|
-
return !!(global.GLOBALS && global._GM_main);
|
|
597
|
-
}
|
|
598
|
-
isUsingSyncAPI() {
|
|
599
|
-
return this._pageCommunicator.isUsingSyncAPI();
|
|
600
|
-
}
|
|
601
|
-
showAppIdWarning() {
|
|
602
|
-
(0, _showAppIdWarning.default)(this);
|
|
603
|
-
}
|
|
604
|
-
createTopMessageBarDriver(optionStream) {
|
|
605
|
-
return new _gmailTopMessageBarDriver.default(optionStream);
|
|
606
|
-
}
|
|
607
|
-
associateThreadAndMessageIDs(threadID, messageID) {
|
|
608
|
-
this._messageIDsToThreadIDs.set(messageID, threadID);
|
|
609
|
-
}
|
|
610
|
-
getThreadIDForMessageID(messageID) {
|
|
611
|
-
return (0, _getOrFail.default)(this._messageIDsToThreadIDs, messageID);
|
|
612
|
-
}
|
|
613
|
-
getDraftIDForMessageID(messageID) {
|
|
614
|
-
let skipCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
615
|
-
return (0, _getDraftIdForMessageId.default)(this, messageID, skipCache);
|
|
616
|
-
}
|
|
617
|
-
reportRecentSyncDraftId(syncDraftId) {
|
|
618
|
-
const count = this._recentSyncDraftIds.get(syncDraftId);
|
|
619
|
-
const newCount = (count ?? 0) + 1;
|
|
620
|
-
this._recentSyncDraftIds.set(syncDraftId, newCount);
|
|
621
|
-
}
|
|
622
|
-
reportDraftClosed(syncDraftId) {
|
|
623
|
-
_kefir.default.later(30 * 1000).takeUntilBy(this._stopper).onValue(() => {
|
|
624
|
-
const count = this._recentSyncDraftIds.get(syncDraftId);
|
|
625
|
-
let newCount;
|
|
626
|
-
if (count == null || count < 1) {
|
|
627
|
-
newCount = 0;
|
|
628
|
-
this._logger.error(new Error('_recentSyncDraftIds count had unexpected value'), {
|
|
629
|
-
count
|
|
591
|
+
}
|
|
592
|
+
_setupComposeViewDriverStream() {
|
|
593
|
+
this._composeViewDriverStream = setupComposeViewDriverStream(this, this._messageViewDriverStream, this._xhrInterceptorStream).takeUntilBy(this._stopper);
|
|
594
|
+
}
|
|
595
|
+
_setupRouteSubViewDriver(viewName) {
|
|
596
|
+
return this._routeViewDriverStream.flatMap((gmailRouteView) => {
|
|
597
|
+
return gmailRouteView
|
|
598
|
+
.getEventStream()
|
|
599
|
+
.filter((event) => event.eventName === viewName)
|
|
600
|
+
.map((event) => event.view);
|
|
630
601
|
});
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
602
|
+
}
|
|
603
|
+
_setupThreadRowViewDriverKefirStream() {
|
|
604
|
+
this._threadRowViewDriverKefirStream = this._rowListViewDriverStream
|
|
605
|
+
.flatMap((rowListViewDriver) => rowListViewDriver.getRowViewDriverStream())
|
|
606
|
+
.takeUntilBy(this._stopper);
|
|
607
|
+
}
|
|
608
|
+
_setupToolbarViewDriverStream() {
|
|
609
|
+
this._toolbarViewDriverLiveSet = toLiveSet(Kefir.merge([
|
|
610
|
+
this._rowListViewDriverStream.map((gmailRowListView) => gmailRowListView.getToolbarView()),
|
|
611
|
+
this.getThreadViewDriverStream().map((gmailThreadView) => gmailThreadView.getToolbarView()),
|
|
612
|
+
])
|
|
613
|
+
.filter(Boolean)
|
|
614
|
+
.flatMap((gmailToolbarView) => gmailToolbarView.waitForReady())
|
|
615
|
+
.map((gmailToolbarView) => ({
|
|
616
|
+
el: gmailToolbarView,
|
|
617
|
+
removalStream: gmailToolbarView.getStopper(),
|
|
618
|
+
}))
|
|
619
|
+
.takeUntilBy(this._stopper));
|
|
620
|
+
this._toolbarViewDriverLiveSet.subscribe({});
|
|
621
|
+
}
|
|
622
|
+
_setupMessageViewDriverStream() {
|
|
623
|
+
this._messageViewDriverStream = this.getThreadViewDriverStream()
|
|
624
|
+
.flatMap((gmailThreadView) => gmailThreadView.getMessageViewDriverStream())
|
|
625
|
+
.takeUntilBy(this._stopper);
|
|
626
|
+
}
|
|
627
|
+
async addGlobalSidebarContentPanel(descriptor) {
|
|
628
|
+
await this.waitForGlobalSidebarReady()
|
|
629
|
+
.merge(this._stopper.flatMap(() => Kefir.constantError(new Error('Driver instance was destroyed early'))))
|
|
630
|
+
.take(1)
|
|
631
|
+
.takeErrors(1)
|
|
632
|
+
.toPromise();
|
|
633
|
+
const appSidebar = this.getGlobalSidebar();
|
|
634
|
+
return appSidebar.addGlobalSidebarContentPanel(descriptor);
|
|
635
|
+
}
|
|
636
|
+
waitForGlobalSidebarReady() {
|
|
637
|
+
const condition = () => GmailElementGetter.getCompanionSidebarContentContainerElement() &&
|
|
638
|
+
(GmailElementGetter.getCompanionSidebarIconContainerElement() ||
|
|
639
|
+
GmailElementGetter.getAddonSidebarContainerElement());
|
|
640
|
+
if (condition()) {
|
|
641
|
+
return Kefir.constant(undefined);
|
|
642
|
+
}
|
|
643
|
+
return waitFor(condition).map(() => undefined);
|
|
644
|
+
}
|
|
645
|
+
getGlobalSidebar() {
|
|
646
|
+
let appSidebarView = this._appSidebarView;
|
|
647
|
+
if (!appSidebarView) {
|
|
648
|
+
const companionSidebarContentContainerEl = GmailElementGetter.getCompanionSidebarContentContainerElement();
|
|
649
|
+
if (!companionSidebarContentContainerEl)
|
|
650
|
+
throw new Error('did not find companionSidebarContentContainerEl');
|
|
651
|
+
appSidebarView = this._appSidebarView = new GmailAppSidebarView(this, companionSidebarContentContainerEl);
|
|
652
|
+
}
|
|
653
|
+
return appSidebarView;
|
|
654
|
+
}
|
|
655
|
+
isRunningInPageContext() {
|
|
656
|
+
return !!(global.GLOBALS && global._GM_main);
|
|
657
|
+
}
|
|
658
|
+
isUsingSyncAPI() {
|
|
659
|
+
return this._pageCommunicator.isUsingSyncAPI();
|
|
660
|
+
}
|
|
661
|
+
showAppIdWarning() {
|
|
662
|
+
showAppIdWarning(this);
|
|
663
|
+
}
|
|
664
|
+
createTopMessageBarDriver(optionStream) {
|
|
665
|
+
return new GmailTopMessageBarDriver(optionStream);
|
|
666
|
+
}
|
|
667
|
+
associateThreadAndMessageIDs(threadID, messageID) {
|
|
668
|
+
this._messageIDsToThreadIDs.set(messageID, threadID);
|
|
669
|
+
}
|
|
670
|
+
getThreadIDForMessageID(messageID) {
|
|
671
|
+
return get(this._messageIDsToThreadIDs, messageID);
|
|
672
|
+
}
|
|
673
|
+
getDraftIDForMessageID(messageID, skipCache = false) {
|
|
674
|
+
return getDraftIDForMessageID(this, messageID, skipCache);
|
|
675
|
+
}
|
|
676
|
+
_recentSyncDraftIds = new Map();
|
|
677
|
+
reportRecentSyncDraftId(syncDraftId) {
|
|
678
|
+
const count = this._recentSyncDraftIds.get(syncDraftId);
|
|
679
|
+
const newCount = (count ?? 0) + 1;
|
|
637
680
|
this._recentSyncDraftIds.set(syncDraftId, newCount);
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
681
|
+
}
|
|
682
|
+
reportDraftClosed(syncDraftId) {
|
|
683
|
+
Kefir.later(30 * 1000, undefined)
|
|
684
|
+
.takeUntilBy(this._stopper)
|
|
685
|
+
.onValue(() => {
|
|
686
|
+
const count = this._recentSyncDraftIds.get(syncDraftId);
|
|
687
|
+
let newCount;
|
|
688
|
+
if (count == null || count < 1) {
|
|
689
|
+
newCount = 0;
|
|
690
|
+
this._logger.error(new Error('_recentSyncDraftIds count had unexpected value'), {
|
|
691
|
+
count,
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
newCount = count - 1;
|
|
696
|
+
}
|
|
697
|
+
if (newCount === 0) {
|
|
698
|
+
this._recentSyncDraftIds.delete(syncDraftId);
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
this._recentSyncDraftIds.set(syncDraftId, newCount);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
isRecentSyncDraftId(syncMessageId) {
|
|
706
|
+
return this._recentSyncDraftIds.has(syncMessageId);
|
|
707
|
+
}
|
|
708
|
+
_selectedThreadRows = t.mapcat((gmailRowListView) => gmailRowListView.getSelectedThreadRowViewDrivers());
|
|
709
|
+
getSelectedThreadRowViewDrivers() {
|
|
710
|
+
if (!this._currentRouteViewDriver) {
|
|
711
|
+
return [];
|
|
712
|
+
}
|
|
713
|
+
return t.toArray(this._currentRouteViewDriver.getRowListViews(), this._selectedThreadRows);
|
|
714
|
+
}
|
|
715
|
+
_threadRowViewSelectionChanges = kefirBus();
|
|
716
|
+
signalThreadRowViewSelectionChange() {
|
|
717
|
+
this._threadRowViewSelectionChanges.value(undefined);
|
|
718
|
+
}
|
|
719
|
+
registerThreadRowViewSelectionHandler(handler) {
|
|
720
|
+
this._threadRowViewSelectionChanges.onValue(handler);
|
|
721
|
+
return () => {
|
|
722
|
+
this._threadRowViewSelectionChanges.offValue(handler);
|
|
723
|
+
};
|
|
724
|
+
}
|
|
659
725
|
}
|
|
660
|
-
|
|
661
|
-
exports.default = _default;
|
|
726
|
+
export default GmailDriver;
|