mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 04:53:17 +00:00
system-util: Set User-Agent from main process.
* Sets user-agent config item when the app's DOM is ready. * App sends the right User-Agent to the server-settings API. Fixes #817.
This commit is contained in:
committed by
Akash Nimare
parent
3fd8aedf81
commit
99b154b8ae
@@ -8,7 +8,7 @@ import path = require('path');
|
||||
import fs = require('fs');
|
||||
import isDev = require('electron-is-dev');
|
||||
import electron = require('electron');
|
||||
const { app, ipcMain } = electron;
|
||||
const { app, ipcMain, session } = electron;
|
||||
|
||||
import AppMenu = require('./menu');
|
||||
import BadgeSettings = require('../renderer/js/pages/preference/badge-settings');
|
||||
@@ -182,6 +182,10 @@ app.on('ready', () => {
|
||||
} else {
|
||||
mainWindow.show();
|
||||
}
|
||||
if (!ConfigUtil.isConfigItemExists('userAgent')) {
|
||||
const userAgent = session.fromPartition('webview:persistsession').getUserAgent();
|
||||
ConfigUtil.setConfigItem('userAgent', userAgent);
|
||||
}
|
||||
});
|
||||
|
||||
page.once('did-frame-finish-load', () => {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { remote } from 'electron';
|
||||
|
||||
import os = require('os');
|
||||
import ConfigUtil = require('./config-util');
|
||||
|
||||
const { app } = remote;
|
||||
let instance: null | SystemUtil = null;
|
||||
@@ -53,6 +54,9 @@ class SystemUtil {
|
||||
}
|
||||
|
||||
getUserAgent(): string | null {
|
||||
if (!this.userAgent) {
|
||||
this.setUserAgent(ConfigUtil.getConfigItem('userAgent', null));
|
||||
}
|
||||
return this.userAgent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user