File tree 3 files changed +11
-8
lines changed
3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useEffect , useState } from 'react' ;
2
- import { NavLink , Route } from 'react-router-dom' ;
2
+ import { NavLink , Route , useHistory } from 'react-router-dom' ;
3
3
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
4
4
import { Helmet } from 'react-helmet' ;
5
5
6
+ import { ipcRenderer } from 'electron' ;
6
7
import MarkdownToHtml from './markdown/MarkdownToHtml' ;
7
8
import UnixTimestamp from './timestamp/UnixTimestamp' ;
8
9
import HtmlPreview from './html/HtmlPreview' ;
@@ -87,11 +88,16 @@ const defaultRoutes = [
87
88
const Main = ( ) => {
88
89
const [ routes , setRoutes ] = useState ( defaultRoutes ) ;
89
90
const [ search , setSearch ] = useState ( '' ) ;
91
+ const history = useHistory ( ) ;
90
92
91
93
const handleSearch = ( e : { target : { value : string } } ) => {
92
94
setSearch ( e . target . value ) ;
93
95
} ;
94
96
97
+ ipcRenderer . on ( 'hot-key-called' , ( ) => {
98
+ history . push ( '/auto' ) ;
99
+ } ) ;
100
+
95
101
useEffect ( ( ) => {
96
102
if ( search . trim ( ) ) {
97
103
setRoutes (
Original file line number Diff line number Diff line change 1
1
import { clipboard , ipcRenderer } from 'electron' ;
2
2
import path from 'path' ;
3
3
import React , { useEffect , useState } from 'react' ;
4
- import { useHistory } from 'react-router-dom' ;
4
+ import { useHistory , useLocation } from 'react-router-dom' ;
5
5
6
6
const detectRouteData = ( value : string ) => {
7
7
const intVal = parseInt ( value , 10 ) ;
@@ -26,14 +26,11 @@ const Auto = () => {
26
26
const [ value , setValue ] = useState ( '' ) ;
27
27
const [ hotkey , setHotkey ] = useState ( '' ) ;
28
28
const history = useHistory ( ) ;
29
-
30
- ipcRenderer . on ( 'hot-key-called' , ( ) => {
31
- setValue ( clipboard . readText ( ) ) ;
32
- } ) ;
29
+ const location = useLocation ( ) ;
33
30
34
31
useEffect ( ( ) => {
35
32
setValue ( clipboard . readText ( ) ) ;
36
- } , [ ] ) ;
33
+ } , [ location ] ) ;
37
34
38
35
useEffect ( ( ) => {
39
36
ipcRenderer
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " plainbelt" ,
3
3
"productName" : " plainbelt" ,
4
- "version" : " 0.0.6 " ,
4
+ "version" : " 0.0.7 " ,
5
5
"description" : " A toolbelt for all your plain text" ,
6
6
"main" : " ./main.prod.js" ,
7
7
"author" : {
You can’t perform that action at this time.
0 commit comments