Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor44 committed Oct 5, 2023
2 parents 4b455f7 + cd5710a commit b410198
Show file tree
Hide file tree
Showing 50 changed files with 604 additions and 407 deletions.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

- Application version: _[e.g. 2.2.1]_
- OS: _[Windows 10, MacOS 13.4, CentOS 7 ...]_

**Steps to Reproduce:**

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

<!-- Describe the feature you'd like. -->
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Question
about: Ask your question
title: ''
labels: question
assignees: ''

---


2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime = electron
disturl = https://electronjs.org/headers
target = 24.8.1
target = 25.8.2
arch = x64
#arch = arm64
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.14.0
18.15.0
8 changes: 7 additions & 1 deletion app/app-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { ipcRenderer } from 'electron';
import * as remote from '@electron/remote';
import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory';
import ApolloClient from 'apollo-client';
import { join } from 'path';
import { PubSub } from 'graphql-subscriptions';
// @ts-ignore no declaration file
import { updateUI } from 'redux-ui/transpiled/action-reducer';
// @ts-ignore no declaration file
import { openProcessManager, setFullScreenState, setOnlineStatus, toggleKbdShortcuts } from './app/duck';
import { getFocus } from './app/selectors';
import {
Expand All @@ -22,10 +22,13 @@ import {
import { dispatchUrl } from './applications/duck';
import ManifestProvider from './applications/manifest-provider/manifest-provider';
import DistantFetcher from './applications/manifest-provider/distant-fetcher';
// @ts-ignore no declaration file
import { getForeFrontNavigationStateProperty } from './applications/utils';
// @ts-ignore no declaration file
import { setReleaseNotesSubdockVisibility } from './auto-update/duck';
import * as bang from './bang/duck';
import { AlertDialogProviderServiceImpl } from './dialogs/alertDialogProvider';
// @ts-ignore no declaration file
import * as inTabSearch from './in-tab-search/duck';
import * as notificationCenter from './notification-center/duck';
import { NotificationProps } from './notification-center/types';
Expand Down Expand Up @@ -54,6 +57,7 @@ import GenericWindowManager from './windows/utils/GenericWindowManager';
import MainWindowManager from './windows/utils/MainWindowManager';
import URLRouter from './urlrouter/URLRouter';
import { closeCurrentTab } from './tabs/duck';
import { BrowserWindowManagerProviderServiceImpl } from './services/services/browser-window/worker';

export class BrowserXAppWorker {
public store: StationStoreWorker;
Expand Down Expand Up @@ -321,6 +325,7 @@ export class BrowserXAppWorker {
}

private initWindowManager() {
services.browserWindow.setProvider(new BrowserWindowManagerProviderServiceImpl(this.store));
GenericWindowManager.store = this.store;
this.mainWindowManager = new MainWindowManager();
this.mainWindowManager.on('enter-full-screen', () => this.dispatch(setFullScreenState(true)));
Expand Down Expand Up @@ -355,6 +360,7 @@ export class BrowserXAppWorker {
const { dispatch } = this.store;
const mainWindowManager = this.mainWindowManager;
const handleMenuItemClick = this.handleMenuItemClick.bind(this);

// install the menu
services.menu.addObserver(observer({
onClickItem(param: any) {
Expand Down
16 changes: 14 additions & 2 deletions app/app/duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const READY = 'browserX/app/READY';
export const CHANGE_APP_FOCUS_STATE = 'browserX/app/CHANGE_APP_FOCUS_STATE';
export const SET_AUTO_LAUNCH_ENABLED = 'browserX/app/SET_AUTO_LAUNCH_ENABLED';
export const ENABLE_AUTO_LAUNCH = 'browserX/app/ENABLE_AUTO_LAUNCH';
export const SET_HIDE_MAIN_MENU = 'browserX/app/SET_HIDE_MAIN_MENU';
export const HIDE_MAIN_MENU = 'browserX/app/HIDE_MAIN_MENU';
export const INCLUDE_BETA_IN_UPDATES = 'browserX/app/INCLUDE_BETA_IN_UPDATES';
export const SET_INCLUDES_BETA_IN_UPDATES = 'browserX/app/SET_INCLUDES_BETA_IN_UPDATES';
export const SET_FULL_SCREEN_STATE = 'browserX/app/SET_FULL_SCREEN_STATE';
Expand Down Expand Up @@ -47,6 +49,14 @@ export const enableAutoLaunch = (enable = true) => ({
type: ENABLE_AUTO_LAUNCH, enable
});

export const setHideMainMenu = (hide) => ({
type: SET_HIDE_MAIN_MENU, hide
});

export const hideMainMenu = (hide) => ({
type: HIDE_MAIN_MENU, hide
});

export const includeBetaInUpdates = (include = true) => ({
type: INCLUDE_BETA_IN_UPDATES, include
});
Expand Down Expand Up @@ -132,6 +142,9 @@ export default function app(state = new Map(), action) {
case SET_AUTO_LAUNCH_ENABLED:
return state.set('autoLaunchEnabled', action.enabled);

case SET_HIDE_MAIN_MENU:
return state.set('hideMainMenu', action.hide);

case SET_INCLUDES_BETA_IN_UPDATES:
return state.set('includesBetaInUpdates', action.included);

Expand Down Expand Up @@ -162,9 +175,8 @@ export default function app(state = new Map(), action) {
case KEYBOARD_LAYOUT_CHANGE:
return state.set('keyboardLayout', action.layout);

case TOGGLE_PROMPT_DOWNLOAD: {
case TOGGLE_PROMPT_DOWNLOAD:
return state.set('promptDownload', Boolean(action.promptDownload));
}

case SET_APP_METADATA:
return state
Expand Down
12 changes: 10 additions & 2 deletions app/app/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { distinctUntilChanged, map } from 'rxjs/operators';
import { subscribeStore } from '../utils/observable';
import { Resolvers } from '../graphql/resolvers-types.generated';

import { getAppAutoLaunchEnabledStatus, getPromptDownloadEnabled } from './selectors';
import { getAppAutoLaunchEnabledStatus, getAppHideMainMenuStatus, getPromptDownloadEnabled } from './selectors';
import { getStationStatus } from '../app/selectors';
import { enableAutoLaunch, togglePromptDownload } from './duck';
import { enableAutoLaunch, hideMainMenu, togglePromptDownload } from './duck';

const resolvers: Resolvers = {
Query: {
autoLaunchEnabled: (_obj, _args, context) => {
return subscribeStore(context.store, getAppAutoLaunchEnabledStatus)
.pipe(map(Boolean), distinctUntilChanged());
},
hideMainMenu: (_obj, _args, context) => {
return subscribeStore(context.store, getAppHideMainMenuStatus)
.pipe(map(Boolean), distinctUntilChanged());
},
promptDownloadEnabled: (_obj, _args, context) => {
return subscribeStore(context.store, getPromptDownloadEnabled)
.pipe(map(Boolean), distinctUntilChanged());
Expand All @@ -32,6 +36,10 @@ const resolvers: Resolvers = {
context.store.dispatch(enableAutoLaunch(args.enabled));
return true;
},
setHideMainMenu: (_obj, args, context) => {
context.store.dispatch(hideMainMenu(args.hide));
return true;
},
setPromptDownload: (_obj, args, context) => {
context.store.dispatch(togglePromptDownload(args.enabled));
return true;
Expand Down
21 changes: 18 additions & 3 deletions app/app/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import {
callService,
serviceAddObserverChannel,
takeEveryWitness,
takeLatestWitness
} from '../utils/sagas';
import {
CHANGE_APP_FOCUS_STATE,
ENABLE_AUTO_LAUNCH,
enableAutoLaunch,
ENABLE_AUTO_LAUNCH, enableAutoLaunch,
HIDE_MAIN_MENU, hideMainMenu,
INCLUDE_BETA_IN_UPDATES,
keyboardLayoutChanged,
OPEN_PROCESS_MANAGER,
Expand All @@ -44,6 +43,7 @@ import { getWindowCurrentTabId } from '../windows/get';
import { getWindow } from '../windows/selectors';
import {
getAppAutoLaunchEnabledStatus,
getAppHideMainMenuStatus,
getPromptDownloadEnabled,
isFullyReady,
isKbdShortcutsOverlayVisible
Expand Down Expand Up @@ -87,6 +87,19 @@ function* sagaEnableAutoLaunch({ enable }) {
yield call([services.autolaunch, services.autolaunch.set], enable);
}

function* sagaSyncHideMainMenu() {
let isHide = yield select(getAppHideMainMenuStatus);
if (typeof isHide === 'undefined') {
isHide = false;
}

yield put(hideMainMenu(isHide));
}

function* sagaHideMainMenu({ hide }) {
yield call([services.browserWindow, services.browserWindow.hideMainMenu], hide);
}

function* sagaTogglePromptDownload({ promptDownload }) {
yield call(
[services.download, services.download.setShouldShowPromptPathOnDownload],
Expand Down Expand Up @@ -252,8 +265,10 @@ export default function* main(bxApp) {
takeEveryWitness(READY, sagaLoadAppMetadata),
takeEveryWitness(READY, sagaPrepareQuit, bxApp),
takeEveryWitness(REHYDRATION_COMPLETE, sagaSyncAutoLaunch),
takeEveryWitness(REHYDRATION_COMPLETE, sagaSyncHideMainMenu),
takeEveryWitness(REHYDRATION_COMPLETE, sagaSyncPromptDownload),
takeEveryWitness(ENABLE_AUTO_LAUNCH, sagaEnableAutoLaunch),
takeEveryWitness(HIDE_MAIN_MENU, sagaHideMainMenu),
takeEveryWitness(TOGGLE_PROMPT_DOWNLOAD, sagaTogglePromptDownload),
takeEveryWitness(INCLUDE_BETA_IN_UPDATES, sagaIncludeBetaInUpdates),
takeEveryWitness(TOGGLE_MAXIMIZE, sagaSendToggleMaximize),
Expand Down
9 changes: 6 additions & 3 deletions app/app/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ export const getStationStatus = (state: StationState): StationStatus => state.ge
export const getAppAutoLaunchEnabledStatus = (state: StationState): boolean | undefined =>
getStationStatus(state).get('autoLaunchEnabled');

export const getAppHideMainMenuStatus = (state: StationState): boolean | undefined =>
getStationStatus(state).get('hideMainMenu');

export const areBetaIncludedInUpdates = (state: StationState): boolean =>
state.getIn(['app', 'includesBetaInUpdates'], false);
state.getIn(['app', 'includesBetaInUpdates'], false);

export const isFullScreen = (state: StationState): boolean =>
Boolean(state.getIn(['app', 'isFullScreen']));
Boolean(state.getIn(['app', 'isFullScreen']));

export const getFocus = (state: StationState): number | undefined =>
getStationStatus(state).get('focus');
getStationStatus(state).get('focus');

export const getPromptDownloadEnabled = (state: StationState): boolean =>
getStationStatus(state).get('promptDownload');
Expand Down
1 change: 1 addition & 0 deletions app/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type StationApp = {
appVersion: string,
includesBetaInUpdates: boolean,
autoLaunchEnabled: boolean,
hideMainMenu: boolean,
isFullScreen: boolean,
defaultDownloadFolder: string,
downloadFolder: string,
Expand Down
10 changes: 9 additions & 1 deletion app/applications/duck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ export type RemoteUpdateInstalledApplicationsAction = {
};
export type DispatchURLAction = {
type: DISPATCH_URL,
url: string, origin?: { tabId?: string, applicationId?: string }, options?: { target: Targets },
url: string,
origin?: {
tabId?: string,
applicationId?: string
},
options?: {
target?: Targets,
loadInBackground?: boolean,
},
};
export type ToggleNotificationsAction = {
type: TOGGLE_NOTIFICATIONS, applicationId: string,
Expand Down
4 changes: 4 additions & 0 deletions app/database/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const App = db.define(
type: Sequelize.BOOLEAN,
defaultValue: true,
},
hideMainMenu: {
type: Sequelize.BOOLEAN,
defaultValue: false,
},
downloadFolder: {
type: Sequelize.STRING,
},
Expand Down
19 changes: 9 additions & 10 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
type Query {
"""Is launch at startup enabled or not."""
""" Is launch at startup enabled or not. """
autoLaunchEnabled: Boolean,
""" Hide main menu (Windows, Linux) """
hideMainMenu: Boolean,

promptDownloadEnabled: Boolean,

Expand Down Expand Up @@ -38,19 +40,16 @@ type Query {
}

type Mutation {
"""
Will set the value of auto-launch.
"""
""" Will set the value of auto-launch. """
setAutoLaunch(
"""
True if autolaunch should be enabled
"""
""" True if autolaunch should be enabled """
enabled: Boolean!
): Boolean,

setPromptDownload(
enabled: Boolean!
):Boolean
""" Will set the value of hideMainMenu property. """
setHideMainMenu(hide: Boolean!): Boolean,

setPromptDownload(enabled: Boolean!):Boolean

"""Trigger an action to check for updates"""
checkForUpdates: Boolean,
Expand Down
4 changes: 3 additions & 1 deletion app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ const lazyBxAppMain = () => {
};

const init = () => {

app.commandLine.appendSwitch('allow-insecure-localhost');

overrideUserDataPath();
applyLogLevel();

if (process.argv.indexOf('database') !== -1) {
loadCliWindow('database').catch(console.error);
return;
}
if (require('electron-squirrel-startup')) return;

initWorker();

Expand Down
19 changes: 13 additions & 6 deletions app/notification-center/lib/ElectronNotificationStatePoller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import ms = require('ms');
import { getDoNotDisturb } from '@stack-inc/electron-notification-state';

import services from '../../services/servicesManager';

export default class ElectronNotificationStatePoller extends EventEmitter {
interval: number;
Expand All @@ -10,6 +10,7 @@ export default class ElectronNotificationStatePoller extends EventEmitter {
constructor() {
super();

const ms = require('ms');
this.interval = ms('1sec');
this.intervalId = undefined;
this.state = null;
Expand All @@ -19,10 +20,16 @@ export default class ElectronNotificationStatePoller extends EventEmitter {

start() {
this.intervalId = setInterval(() => {
if (getDoNotDisturb() !== this.state) {
this.emit('os-dnd-state', getDoNotDisturb());
this.state = getDoNotDisturb();
}
services.osNotification.isDoNotDisturbEnabled()
.then(doNotDisturb => {
if (doNotDisturb !== this.state) {
this.emit('os-dnd-state', doNotDisturb);
this.state = doNotDisturb;
}
})
.catch(e => {
console.log('Error while polling OS notification state', e);
});
}, this.interval);
}

Expand Down
Loading

0 comments on commit b410198

Please sign in to comment.