From e35c882a773aa192498138a08429d64954f4f01b Mon Sep 17 00:00:00 2001 From: Melody Wei Date: Fri, 22 Dec 2017 22:57:28 +0800 Subject: prevent drag event from bubbling --- src/app.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/app.js b/src/app.js index a0b88611c..8e62776d2 100644 --- a/src/app.js +++ b/src/app.js @@ -105,3 +105,5 @@ window.addEventListener('load', () => { // Prevent drag and drop into window from redirecting window.addEventListener('dragover', event => event.preventDefault()); window.addEventListener('drop', event => event.preventDefault()); +window.addEventListener('dragover', event => event.stopPropagation()); +window.addEventListener('drop', event => event.stopPropagation()); -- cgit v1.2.3-70-g09d2 From d422d2e160e818dd0bff90707d0c0832c8c3367b Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 22 Dec 2017 20:53:45 +0100 Subject: setBadge debugging --- src/stores/ServicesStore.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 66f37af26..2417181e6 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -503,6 +503,7 @@ export default class ServicesStore extends Store { // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases if (showMessageBadgesEvenWhenMuted) { + console.log('set badge', unreadDirectMessageCount, unreadIndirectMessageCount); this.actions.app.setBadge({ unreadDirectMessageCount, unreadIndirectMessageCount, -- cgit v1.2.3-70-g09d2 From 344c25061f6a780da2db55e1ec5a66024a580dba Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 22 Dec 2017 23:20:48 +0100 Subject: Fix indirect message badge being displayed when disabled --- src/stores/ServicesStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 2417181e6..c48f48a88 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -497,7 +497,7 @@ export default class ServicesStore extends Store { .reduce((a, b) => a + b, 0); const unreadIndirectMessageCount = this.allDisplayed - .filter(s => (showMessageBadgeWhenMuted || s.isIndirectMessageBadgeEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) + .filter(s => (showMessageBadgeWhenMuted && showMessageBadgesEvenWhenMuted) && (s.isBadgeEnabled && s.isIndirectMessageBadgeEnabled)) .map(s => s.unreadIndirectMessageCount) .reduce((a, b) => a + b, 0); -- cgit v1.2.3-70-g09d2 From 7293492403d8d4c8441eb58cdb391f5476608cfa Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sat, 23 Dec 2017 00:02:30 +0100 Subject: fix(Service): Ctrl/Cmd+R now navigates back to the service root --- src/stores/ServicesStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 66f37af26..6c1e757dc 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -368,7 +368,7 @@ export default class ServicesStore extends Store { const service = this.one(serviceId); service.resetMessageCount(); - service.webview.reload(); + service.webview.loadURL(service.url); } @action _reloadActive() { -- cgit v1.2.3-70-g09d2 From 531531e182b59dd4dab23d3f68717d609cdb7dd4 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 24 Dec 2017 21:40:49 +0100 Subject: fix(App): Fix service reload after waking machine up --- src/stores/AppStore.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 5a6c12ee1..7e2be5e9f 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -124,15 +124,23 @@ export default class AppStore extends Store { this.stores.router.push(data.url); }); + const TIMEOUT = 5000; // Check system idle time every minute setInterval(() => { this.idleTime = idleTimer.getIdleTime(); - }, 60000); + }, TIMEOUT); // Reload all services after a healthy nap - powerMonitor.on('resume', () => { - setTimeout(window.location.reload, 5000); - }); + // Alternative solution for powerMonitor as the resume event is not fired + // More information: https://github.com/electron/electron/issues/1615 + let lastTime = (new Date()).getTime(); + setInterval(() => { + const currentTime = (new Date()).getTime(); + if (currentTime > (lastTime + TIMEOUT + 2000)) { + this._reactivateServices(); + } + lastTime = currentTime; + }, TIMEOUT); // Set active the next service key( @@ -357,6 +365,16 @@ export default class AppStore extends Store { return autoLauncher.isEnabled() || false; } + _reactivateServices(retryCount = 0) { + if (!this.isOnline) { + console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount) + return setTimeout(() => this._reactivateServices(retryCount + 1), 5000); + } + + console.debug('reactivateServices: reload all services'); + this.actions.service.reloadAll(); + } + _systemDND() { const dnd = getDoNotDisturb(); if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { -- cgit v1.2.3-70-g09d2 From b79c997b2316a60ebe7920f263c1edbc582c852e Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 24 Dec 2017 21:44:55 +0100 Subject: Fix linting issue --- src/stores/AppStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 7e2be5e9f..ea51b537a 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -367,7 +367,7 @@ export default class AppStore extends Store { _reactivateServices(retryCount = 0) { if (!this.isOnline) { - console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount) + console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount); return setTimeout(() => this._reactivateServices(retryCount + 1), 5000); } -- cgit v1.2.3-70-g09d2 From fa73612e38ccfab17bc7c39f8b92153903a7ca83 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 26 Dec 2017 13:52:50 +0100 Subject: Fix linting issues pt 2 --- src/stores/AppStore.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index ea51b537a..aa6e801ff 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -14,7 +14,7 @@ import locales from '../i18n/translations'; import { gaEvent } from '../lib/analytics'; import Miner from '../lib/Miner'; -const { app, powerMonitor } = remote; +const { app } = remote; const defaultLocale = DEFAULT_APP_SETTINGS.locale; const autoLauncher = new AutoLaunch({ name: 'Franz', @@ -368,11 +368,11 @@ export default class AppStore extends Store { _reactivateServices(retryCount = 0) { if (!this.isOnline) { console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount); - return setTimeout(() => this._reactivateServices(retryCount + 1), 5000); + setTimeout(() => this._reactivateServices(retryCount + 1), 5000); + } else { + console.debug('reactivateServices: reload all services'); + this.actions.service.reloadAll(); } - - console.debug('reactivateServices: reload all services'); - this.actions.service.reloadAll(); } _systemDND() { -- cgit v1.2.3-70-g09d2 From 7e784c699554dd85be3e9e219c59578995cadd38 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 3 Jan 2018 15:22:05 +0100 Subject: feat(Services): Improve user experience of service search --- .../settings/recipes/RecipesDashboard.js | 20 +++++---- .../settings/services/ServicesDashboard.js | 42 +++++++++++++++---- src/components/ui/SearchInput.js | 48 ++++++++-------------- src/containers/settings/ServicesScreen.js | 1 + src/i18n/locales/en-US.json | 1 + src/styles/searchInput.scss | 16 ++++++++ src/styles/settings.scss | 22 +--------- 7 files changed, 85 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/components/settings/recipes/RecipesDashboard.js b/src/components/settings/recipes/RecipesDashboard.js index b6ade5da4..4610c69a5 100644 --- a/src/components/settings/recipes/RecipesDashboard.js +++ b/src/components/settings/recipes/RecipesDashboard.js @@ -16,6 +16,10 @@ const messages = defineMessages({ id: 'settings.recipes.headline', defaultMessage: '!!!Available Services', }, + searchService: { + id: 'settings.searchService', + defaultMessage: '!!!Search service', + }, mostPopularRecipes: { id: 'settings.recipes.mostPopular', defaultMessage: '!!!Most popular', @@ -81,13 +85,7 @@ export default class RecipesDashboard extends Component { return (
- searchRecipes(e)} - onReset={() => resetSearch()} - throttle - /> +

{intl.formatMessage(messages.headline)}

{serviceStatus.length > 0 && serviceStatus.includes('created') && ( @@ -101,7 +99,13 @@ export default class RecipesDashboard extends Component { )} - {/* {!searchNeedle && ( */} + searchRecipes(e)} + onReset={() => resetSearch()} + autoFocus + throttle + />
- filterServices({ needle })} - onReset={() => resetFilter()} - /> +

{intl.formatMessage(messages.headline)}

+ {!isLoading && ( + filterServices({ needle })} + onReset={() => resetFilter()} + autoFocus + /> + )} {!isLoading && servicesRequestFailed && (
)} - {!isLoading && services.length === 0 && ( + {!isLoading && services.length === 0 && !searchNeedle && (

@@ -132,6 +150,16 @@ export default class ServicesDashboard extends Component { {intl.formatMessage(messages.discoverServices)}

)} + {!isLoading && services.length === 0 && searchNeedle && ( +
+

+ + + + {intl.formatMessage(messages.noServiceFound)} +

+
+ )} {isLoading ? ( ) : ( diff --git a/src/components/ui/SearchInput.js b/src/components/ui/SearchInput.js index bca412cef..a94cde201 100644 --- a/src/components/ui/SearchInput.js +++ b/src/components/ui/SearchInput.js @@ -9,36 +9,46 @@ import { debounce } from 'lodash'; export default class SearchInput extends Component { static propTypes = { value: PropTypes.string, - defaultValue: PropTypes.string, + placeholder: PropTypes.string, className: PropTypes.string, onChange: PropTypes.func, onReset: PropTypes.func, name: PropTypes.string, throttle: PropTypes.bool, throttleDelay: PropTypes.number, + autoFocus: PropTypes.bool, }; static defaultProps = { value: '', - defaultValue: '', + placeholder: '', className: '', name: uuidv1(), throttle: false, throttleDelay: 250, onChange: () => null, onReset: () => null, + autoFocus: false, } constructor(props) { super(props); this.state = { - value: props.value || props.defaultValue, + value: props.value, }; this.throttledOnChange = debounce(this.throttledOnChange, this.props.throttleDelay); } + componentDidMount() { + const { autoFocus } = this.props; + + if (autoFocus) { + this.input.focus(); + } + } + onChange(e) { const { throttle, onChange } = this.props; const { value } = e.target; @@ -52,26 +62,6 @@ export default class SearchInput extends Component { } } - onClick() { - const { defaultValue } = this.props; - const { value } = this.state; - - if (value === defaultValue) { - this.setState({ value: '' }); - } - - this.input.focus(); - } - - onBlur() { - const { defaultValue } = this.props; - const { value } = this.state; - - if (value === '') { - this.setState({ value: defaultValue }); - } - } - throttledOnChange(e) { const { onChange } = this.props; @@ -79,8 +69,8 @@ export default class SearchInput extends Component { } reset() { - const { defaultValue, onReset } = this.props; - this.setState({ value: defaultValue }); + const { onReset } = this.props; + this.setState({ value: '' }); onReset(); } @@ -88,7 +78,7 @@ export default class SearchInput extends Component { input = null; render() { - const { className, name, defaultValue } = this.props; + const { className, name, placeholder } = this.props; const { value } = this.state; return ( @@ -101,18 +91,16 @@ export default class SearchInput extends Component {