Skip to content

Commit 0b5afb1

Browse files
chore: add central notification (#41)
1 parent fde7e37 commit 0b5afb1

8 files changed

Lines changed: 56 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"pinia": "^2.0.12",
5353
"sanitize-html": "^2.7.0",
5454
"universal-analytics": "^0.5.3",
55+
"vercel-toast": "^1.5.5",
5556
"vue": "^3.2.26",
5657
"vue-router": "^4.0.12",
5758
"vue3-perfect-scrollbar": "^1.6.0"

src/main/store/module/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default new Store<AppStore>({
88
defaults: {
99
bounds: {},
1010
sidebarWidth: 180,
11-
snippetListWidth: 250
11+
snippetListWidth: 250,
12+
notifySupport: false
1213
}
1314
})

src/renderer/App.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
onCopySnippet,
2828
emitter
2929
} from '@/composable'
30+
import { createToast, destroyAllToasts } from 'vercel-toast'
3031
3132
// По какой то причине необходимо явно установить роут в '/'
3233
// для корректного поведения в продакшен сборке
@@ -79,7 +80,39 @@ const trackAppUpdate = () => {
7980
store.app.set('version', appStore.version)
8081
}
8182
83+
const showSupportToast = () => {
84+
if (!store.app.get('notifySupport')) {
85+
const message = document.createElement('div')
86+
87+
setTimeout(() => {
88+
message.innerHTML = `Hi, Anton here 👋<br><br>
89+
I need your support. If you find this app useful, please put a star on <a class="external" href="#">github</a>. It will inspire me to continue development on the project.<br><br>My goal is at least 10k stars.`
90+
91+
createToast(message, {
92+
action: {
93+
text: 'Close',
94+
callback (toast) {
95+
toast.destroy()
96+
store.app.set('notifySupport', true)
97+
track('app/notify', 'support-go-to-github')
98+
}
99+
}
100+
})
101+
102+
const a = document.querySelector('.external')
103+
104+
a?.addEventListener('click', () => {
105+
ipc.invoke('main:open-url', 'https://github.com/massCodeIO/massCode')
106+
store.app.set('notifySupport', true)
107+
destroyAllToasts()
108+
track('app/notify', 'support-close')
109+
})
110+
}, 1000 * 60 * 5)
111+
}
112+
}
113+
82114
init()
115+
showSupportToast()
83116
84117
watch(
85118
() => appStore.theme,

src/renderer/assets/scss/vendor.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@
5454
.ti-autocomplete {
5555
border: 1px solid var(--color-border) !important;
5656
background-color: var(--color-bg) !important;
57+
}
58+
59+
.toast-container {
60+
.toast {
61+
62+
width: 400px;
63+
&-text {
64+
display: flex;
65+
align-items: center;
66+
}
67+
}
5768
}

src/renderer/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { createApp } from 'vue'
22
import { createPinia } from 'pinia'
33
import router from './router'
44
import App from './App.vue'
5-
import './assets/scss/main.scss'
65
import PerfectScrollbar from 'vue3-perfect-scrollbar'
76
import 'vue3-perfect-scrollbar/dist/vue3-perfect-scrollbar.css'
7+
import 'vercel-toast/dist/vercel-toast.css'
8+
import './assets/scss/main.scss'
89

910
createApp(App)
1011
.use(createPinia())

src/shared/types/main/analytics.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type AppEvents =
2424
| 'install'
2525
| 'empty-trash'
2626
| 'set-theme'
27+
| 'notify'
2728

2829
type TrackSnippetEvents = CombineWith<SnippetEvents, 'snippets'>
2930
type TrackFolderEvents = CombineWith<FolderEvents, 'folders'>

src/shared/types/main/store.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface AppStore {
77
sidebarWidth: number
88
snippetListWidth: number
99
version?: string
10+
notifySupport: boolean
1011
}
1112

1213
interface Editor {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11726,6 +11726,11 @@ vendors@^1.0.0:
1172611726
resolved "https://registry.yarnpkg.com/vendors/-/vendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"
1172711727
integrity sha512-/juG65kTL4Cy2su4P8HjtkTxk6VmJDiOPBufWniqQ6wknac6jNiXS9vU+hO3wgusiyqWlzTbVHi0dyJqRONg3w==
1172811728

11729+
vercel-toast@^1.5.5:
11730+
version "1.5.5"
11731+
resolved "https://registry.yarnpkg.com/vercel-toast/-/vercel-toast-1.5.5.tgz#484355b1113b2f602969eddca1ede9157b22c750"
11732+
integrity sha512-MTcNPcy9V+aiHIg5iS9h/3UQXHfY00a5pQv4D14XWOql9sUQuiB3mxQXyARLIHT+HblqZgf4awyaleA/ND16tA==
11733+
1172911734
verror@1.10.0:
1173011735
version "1.10.0"
1173111736
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"

0 commit comments

Comments
 (0)