File tree Expand file tree Collapse file tree 4 files changed +17
-24
lines changed Expand file tree Collapse file tree 4 files changed +17
-24
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,9 @@ app.on('activate', () => {
158
158
} ) ;
159
159
160
160
app . on ( 'ready' , ( ) => {
161
+ const ses = session . fromPartition ( 'persist:webviewsession' ) ;
162
+ ses . setUserAgent ( `ZulipElectron/${ app . getVersion ( ) } ${ ses . getUserAgent ( ) } ` ) ;
163
+
161
164
AppMenu . setMenu ( {
162
165
tabs : [ ]
163
166
} ) ;
@@ -190,10 +193,10 @@ app.on('ready', () => {
190
193
} else {
191
194
mainWindow . show ( ) ;
192
195
}
193
- if ( ! ConfigUtil . isConfigItemExists ( 'userAgent' ) ) {
194
- const userAgent = session . fromPartition ( 'webview:persistsession' ) . getUserAgent ( ) ;
195
- ConfigUtil . setConfigItem ( 'userAgent ', userAgent ) ;
196
- }
196
+ } ) ;
197
+
198
+ ipcMain . on ( 'fetch-user-agent ', event => {
199
+ event . returnValue = session . fromPartition ( 'persist:webviewsession' ) . getUserAgent ( ) ;
197
200
} ) ;
198
201
199
202
page . once ( 'did-frame-finish-load' , ( ) => {
Original file line number Diff line number Diff line change @@ -149,12 +149,6 @@ export default class WebView extends BaseComponent {
149
149
if ( ! isSettingPage ) {
150
150
this . props . switchLoading ( true , this . props . url ) ;
151
151
}
152
- let userAgent = SystemUtil . getUserAgent ( ) ;
153
- if ( ! userAgent ) {
154
- SystemUtil . setUserAgent ( this . $el . getUserAgent ( ) ) ;
155
- userAgent = SystemUtil . getUserAgent ( ) ;
156
- }
157
- this . $el . setUserAgent ( userAgent ) ;
158
152
} ) ;
159
153
160
154
this . $el . addEventListener ( 'did-stop-loading' , ( ) => {
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ class ServerManagerView {
140
140
await this . loadProxy ( ) ;
141
141
this . initDefaultSettings ( ) ;
142
142
this . initSidebar ( ) ;
143
+ this . removeUAfromDisk ( ) ;
143
144
if ( EnterpriseUtil . configFile ) {
144
145
this . initPresetOrgs ( ) ;
145
146
}
@@ -239,6 +240,12 @@ class ServerManagerView {
239
240
this . toggleSidebar ( showSidebar ) ;
240
241
}
241
242
243
+ // Remove the stale UA string from the disk if the app is not freshly
244
+ // installed. This should be removed in a further release.
245
+ removeUAfromDisk ( ) : void {
246
+ ConfigUtil . removeConfigItem ( 'userAgent' ) ;
247
+ }
248
+
242
249
async queueDomain ( domain : any ) : Promise < boolean > {
243
250
// allows us to start adding multiple domains to the app simultaneously
244
251
// promise of addition resolves in both cases, but we consider it rejected
Original file line number Diff line number Diff line change 1
- import { remote } from 'electron' ;
1
+ import { ipcRenderer } from 'electron' ;
2
2
3
3
import os from 'os' ;
4
- import * as ConfigUtil from './config-util' ;
5
-
6
- const { app } = remote ;
7
4
8
5
export const connectivityERR : string [ ] = [
9
6
'ERR_INTERNET_DISCONNECTED' ,
@@ -14,7 +11,7 @@ export const connectivityERR: string[] = [
14
11
'ERR_NETWORK_CHANGED'
15
12
] ;
16
13
17
- let userAgent : string | null = null ;
14
+ const userAgent = ipcRenderer . sendSync ( 'fetch-user-agent' ) ;
18
15
19
16
export function getOS ( ) : string {
20
17
const platform = os . platform ( ) ;
@@ -32,14 +29,6 @@ export function getOS(): string {
32
29
return '' ;
33
30
}
34
31
}
35
-
36
- export function setUserAgent ( webViewUserAgent : string ) : void {
37
- userAgent = `ZulipElectron/${ app . getVersion ( ) } ${ webViewUserAgent } ` ;
38
- }
39
-
40
- export function getUserAgent ( ) : string | null {
41
- if ( ! userAgent ) {
42
- setUserAgent ( ConfigUtil . getConfigItem ( 'userAgent' , null ) ) ;
43
- }
32
+ export function getUserAgent ( ) : string {
44
33
return userAgent ;
45
34
}
You can’t perform that action at this time.
0 commit comments