[READ-ONLY] Mirror of https://github.com/probablykasper/remind-me-again. Toggleable cron reminders app for Mac, Linux and Windows
linux macos notifications reminder tauri windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Add window close `Escape` shortcut

Kasper (Dec 9, 2022, 1:36 AM +0100) bd644ebd b98a9da0

+43 -27
+3
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## Next 4 + - Add `Escape` shortcut for closing the window 5 + 3 6 ## 1.0.2 - 2022 Nov 4 4 7 - Fix tray icon button (and maybe Linux) 5 8
+1 -1
src-tauri/Cargo.toml
··· 16 16 serde = { version = "1.0", features = ["derive"] } 17 17 tokio = { version = "1.19", features = ["macros", "time"] } 18 18 chrono = "0.4" 19 - tauri = { version = "1.2", features = ["devtools", "dialog-message", "macos-private-api", "notification-all", "shell-open", "system-tray"] } 19 + tauri = { version = "1.2", features = ["devtools", "dialog-message", "macos-private-api", "notification-all", "shell-open", "system-tray", "window-hide"] } 20 20 async-cron-scheduler = "1.0" 21 21 tauri-plugin-window-state = "0.1" 22 22 nanoid = "0.4"
+3
src-tauri/tauri.conf.json
··· 58 58 }, 59 59 "shell": { 60 60 "open": true 61 + }, 62 + "window": { 63 + "hide": true 61 64 } 62 65 }, 63 66 "security": {
+19 -5
src/App.svelte
··· 7 7 import New from './lib/New.svelte' 8 8 import { checkShortcut, runCmd } from './lib/helpers' 9 9 import type { Group } from './lib/types' 10 - import { onDestroy, SvelteComponent } from 'svelte' 11 - import { event } from '@tauri-apps/api' 10 + import { onDestroy } from 'svelte' 11 + import { event, window as tauriWindow } from '@tauri-apps/api' 12 12 13 - let groupElements: SvelteComponent[] = [] 13 + let groupElements: Item[] = [] 14 14 let focusedGroup: number | null = null 15 15 16 16 let groups: Group[] = [] ··· 35 35 }, 36 36 }) 37 37 38 + let creatorComponent: New 38 39 const unlistenFuture = event.listen('tauri://menu', ({ payload }) => { 39 40 console.log(payload, focusedGroup) 40 41 if (payload === 'Edit Reminder' && focusedGroup !== null) { 41 42 console.log('--w', groupElements[focusedGroup]) 42 43 groupElements[focusedGroup]?.edit() 44 + } else if (payload === 'New Reminder') { 45 + if (focusedGroup) { 46 + groupElements[focusedGroup].cancel() 47 + } 48 + creatorComponent.open() 43 49 } 44 50 }) 45 51 onDestroy(async () => { 46 - const unlisten = await unlistenFuture 47 - unlisten() 52 + ;(await unlistenFuture)() 48 53 }) 49 54 </script> 50 55 56 + <svelte:body 57 + on:keydown={async (e) => { 58 + if (checkShortcut(e, 'Escape')) { 59 + tauriWindow.appWindow.hide() 60 + } 61 + }} 62 + /> 63 + 51 64 <div class="flex min-h-screen w-full flex-col overflow-y-scroll px-4 pb-2"> 52 65 <h1 class="mb-2 cursor-default select-none text-center text-2xl font-normal text-white"> 53 66 Reminders ··· 55 68 {#if groups} 56 69 <div class="relative select-none outline-none"> 57 70 <New 71 + bind:this={creatorComponent} 58 72 onCreate={(newGroups) => { 59 73 groups = newGroups 60 74 }}
+1
src/lib/Edit.svelte
··· 68 68 <div class="mb-2 flex cursor-default justify-center text-xs text-white"> 69 69 {#each ['sec', 'min', 'hour', 'day', 'month', 'weekday'] as segment, i} 70 70 {@const selected = selectedSegments.includes(i)} 71 + <!-- svelte-ignore a11y-click-events-have-key-events --> 71 72 <div 72 73 class="px-1 hover:opacity-100" 73 74 class:opacity-60={!selected}
+11 -6
src/lib/Item.svelte
··· 37 37 editGroup = JSON.parse(JSON.stringify(group)) 38 38 isEditing = true 39 39 } 40 - async function cancel() { 41 - editGroup = JSON.parse(JSON.stringify(group)) 42 - isEditing = false 43 - await tick() 44 - card.focus() 40 + export async function cancel() { 41 + if (isEditing) { 42 + editGroup = JSON.parse(JSON.stringify(group)) 43 + isEditing = false 44 + await tick() 45 + card.focus() 46 + } 45 47 } 46 48 async function saveEdits() { 47 49 group.title = editGroup.title ··· 54 56 } 55 57 56 58 async function keydown(e: KeyboardEvent) { 57 - if (checkShortcut(e, 'Escape')) { 59 + if (checkShortcut(e, 'Escape') && isEditing) { 58 60 e.preventDefault() 59 61 cancel() 60 62 await tick() 61 63 card.focus() 64 + e.stopPropagation() 62 65 } 63 66 } 64 67 function keydownSelf(e: KeyboardEvent) { ··· 80 83 }} 81 84 /> 82 85 86 + <!-- svelte-ignore a11y-no-noninteractive-tabindex --> 83 87 <div 84 88 bind:this={card} 85 89 class="group mb-3 flex w-full cursor-default items-center rounded-lg p-3.5 text-left shadow-xl outline-none transition-colors duration-150 ease-out focus:bg-[#133134] active:bg-[#133134]" ··· 160 164 <Edit bind:group={editGroup} onCancel={cancel} /> 161 165 {/if} 162 166 </form> 167 + <!-- svelte-ignore a11y-click-events-have-key-events --> 163 168 <div on:click|preventDefault|stopPropagation> 164 169 <Switch 165 170 class="ml-3.5"
+5 -15
src/lib/New.svelte
··· 1 1 <script lang="ts"> 2 - import { onMount, onDestroy } from 'svelte' 2 + import { onMount } from 'svelte' 3 3 import { cubicOut } from 'svelte/easing' 4 4 import { slide } from 'svelte/transition' 5 5 import Edit from './Edit.svelte' 6 6 import type { Group } from './types' 7 7 import { checkShortcut, invisibleCursorFix, runCmd } from './helpers' 8 - import { event } from '@tauri-apps/api' 9 8 10 9 export let onCreate: (newGroups: Group[]) => void 11 10 let editMode = false ··· 41 40 } 42 41 43 42 let titleInput: HTMLInputElement 44 - function newReminder() { 43 + export function open() { 45 44 editMode = true 46 45 titleInput.focus() 47 46 } ··· 49 48 editMode = false 50 49 group = newBlank() 51 50 } 52 - 53 - const unlistenFuture = event.listen('tauri://menu', ({ payload }) => { 54 - if (payload === 'New Reminder') { 55 - newReminder() 56 - } 57 - }) 58 - onDestroy(async () => { 59 - const unlisten = await unlistenFuture 60 - unlisten() 61 - }) 62 51 </script> 63 52 64 53 <form 65 54 class="mb-3 flex w-full flex-col rounded bg-white bg-opacity-10" 66 55 class:p-3.5={editMode} 67 56 on:keydown={(e) => { 68 - if (checkShortcut(e, 'Escape')) { 57 + if (checkShortcut(e, 'Escape') && editMode) { 69 58 cancel() 70 59 e.preventDefault() 60 + e.stopPropagation() 71 61 } 72 62 }} 73 63 on:submit|preventDefault={() => { 74 64 if (editMode) { 75 65 create(group) 76 66 } else { 77 - newReminder() 67 + open() 78 68 } 79 69 }} 80 70 >