Skip to content

Commit

Permalink
Fixed issue in recurrence component, fixed cosmetic issue in drawer r…
Browse files Browse the repository at this point in the history
…egarding the filter reset
  • Loading branch information
ransome1 committed Jan 20, 2025
1 parent 003b884 commit b810555
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
name: Code scan and mirror to opencode.net
name: Code scan, update Flathub and mirror to opencode.net
on:
push:
branches:
- '*'
jobs:
trigger-flathub_build:
name: Trigger Flathub build bot
runs-on: ubuntu-latest
steps:
- name: Trigger Flathub build
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.TRIGGER_FLATHUB_BUILD }}
repository: ransome1/com.github.ransome1.sleek
event-type: trigger-flathub-build
client-payload: '{"commit_id": "${{ github.sha }}"}'
snyk:
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ on:
tags:
- '*'
jobs:
trigger-flathub_build:
name: Trigger Flathub build bot
runs-on: ubuntu-latest
steps:
- name: Trigger Flathub build
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.TRIGGER_FLATHUB_BUILD }}
repository: ransome1/com.github.ransome1.sleek
event-type: trigger-flathub-build
client-payload: '{"commit_id": "${{ github.sha }}"}'
macos:
name: MacOS (Prepare release)
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sleek",
"productName": "sleek",
"version": "2.0.16",
"version": "2.0.17-rc.1",
"description": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"synopsis": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"keywords": [
Expand Down Expand Up @@ -53,7 +53,7 @@
"dayjs": "^1.11.13",
"electron-store": "^10.0.0",
"i18next": "^24.2.0",
"jstodotxt": "^1.0.0-alpha.0",
"jstodotxt": "1.0.0-alpha.3",
"react": "^19.0.0",
"react-autosuggest": "^10.1.0",
"react-dom": "^19.0.0",
Expand Down
56 changes: 21 additions & 35 deletions src/renderer/Dialog/RecurrencePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { withTranslation, WithTranslation } from 'react-i18next'
import { i18n } from '../Settings/LanguageSelector'
import './RecurrencePicker.scss'

const getInterval = (recurrence: string | null): void => recurrence ? recurrence.match(/[a-zA-Z]+/) : null
const getAmount = (recurrence: string | null): void => recurrence ? recurrence.match(/\d+/) : 0
const getStrictIndicator = (recurrence: string | null): void => !!recurrence?.startsWith('+')

interface RecurrencePickerComponentProps extends WithTranslation {
recurrence: string | null
handleChange: (key: string, value: string) => void
Expand All @@ -22,43 +26,16 @@ const RecurrencePickerComponent: React.FC<RecurrencePickerComponentProps> = ({
handleChange,
t
}) => {

const recurrenceFieldRef = useRef<HTMLInputElement | null>(null)
const [strictRecurrence, setStrictRecurrence] = useState<boolean>(false)
const [interval, setInterval] = useState<string | null>(null)
const [amount, setAmount] = useState<string | null>(null)

const handleIntervalChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
if (!amount) setAmount('1')
setInterval(event.target.value)
}

const handleAmountChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
if (!interval) setInterval('d')
setAmount(event.target.value)
}

const handleStrictRecurrenceChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
if (!recurrence) return
setStrictRecurrence(event.target.checked)
}

useEffect(() => {
if (amount && interval) {
const updatedValue = strictRecurrence ? '+' + amount + interval : amount + interval
handleChange('rec', updatedValue)
}
}, [interval, amount, strictRecurrence, handleChange])

useEffect(() => {
const getInterval = (recurrence: string | null): void =>
recurrence ? recurrence.match(/[a-zA-Z]+/) : null
const getAmount = (recurrence: string | null): void =>
recurrence ? recurrence.match(/\d+/) : null
const getStrictIndicator = (recurrence: string | null): void => !!recurrence?.startsWith('+')

setStrictRecurrence(getStrictIndicator(recurrence))
setInterval(getInterval(recurrence))
setAmount(getAmount(recurrence))
setInterval(getInterval(recurrence))
}, [recurrence])

useEffect(() => {
Expand Down Expand Up @@ -94,7 +71,7 @@ const RecurrencePickerComponent: React.FC<RecurrencePickerComponentProps> = ({
<TextField
label={t('todoDialog.recurrencePicker.label')}
className="recurrencePicker"
onChange={() => handleChange('rec', recurrence ?? '')}
onChange={(event) => handleChange('rec', event.target.value ?? '')}
value={recurrence || '-'}
inputRef={recurrenceFieldRef}
data-testid="dialog-picker-recurrence"
Expand All @@ -120,8 +97,11 @@ const RecurrencePickerComponent: React.FC<RecurrencePickerComponentProps> = ({
autoFocus={true}
label={t('todoDialog.recurrencePicker.every')}
type="number"
onChange={handleAmountChange}
defaultValue={amount || '1'}
onChange={(event) => {
const updatedRecurrence = getStrictIndicator(recurrence) ? '+' + event.target.value + getInterval(recurrence) : event.target.value + getInterval(recurrence)
handleChange('rec', updatedRecurrence)
}}
value={amount}
className="recurrencePickerPopupInput"
inputProps={{
min: 0
Expand All @@ -134,8 +114,11 @@ const RecurrencePickerComponent: React.FC<RecurrencePickerComponentProps> = ({
<FormControl>
<RadioGroup
aria-labelledby="recurrencePickerRadioGroup"
value={interval || null}
onChange={handleIntervalChange}
value={interval}
onChange={(event) => {
const updatedRecurrence = getStrictIndicator(recurrence) ? '+' + getAmount(recurrence) + event.target.defaultValue : getAmount(recurrence) + event.target.defaultValue
handleChange('rec', updatedRecurrence)
}}
>
<FormControlLabel
value="d"
Expand Down Expand Up @@ -169,7 +152,10 @@ const RecurrencePickerComponent: React.FC<RecurrencePickerComponentProps> = ({
control={
<Checkbox
checked={strictRecurrence}
onChange={handleStrictRecurrenceChange}
onChange={(event) => {
const updatedRecurrence = event.target.checked ? '+' + getAmount(recurrence) + getInterval(recurrence) : getAmount(recurrence) + getInterval(recurrence)
handleChange('rec', updatedRecurrence)
}}
name="strictRecurrenceCheckbox"
/>
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/Drawer/Attributes.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use '../Variables.scss';

#Attributes {
display: block;
padding: 0.75em 1em;
margin: 0;
overflow-y: scroll;
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/Drawer/Drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
.MuiPaper-root {
position: relative;
z-index: 5;
// .MuiTabs-root {
// min-height: 6em;
// }
.MuiTabs-root {
min-height: 5em;
overflow:visible;
}
.MuiTabs-flexContainer {
button {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3896,10 +3896,10 @@ jsonfile@^6.0.1:
optionalDependencies:
graceful-fs "^4.1.6"

jstodotxt@^1.0.0-alpha.0:
version "1.0.0-alpha.0"
resolved "https://registry.yarnpkg.com/jstodotxt/-/jstodotxt-1.0.0-alpha.0.tgz#49f4c4eafd754f7848d026f648d55a40e86ca9d1"
integrity sha512-D7Dxn6DSJbgnjNABQriBuj16NAz4s0+NhEWIGvMoMqDFHm4X3G9N+c/hCVWIqoy7IN2neSpCcI6IMIS4fmla8Q==
[email protected].3:
version "1.0.0-alpha.3"
resolved "https://registry.yarnpkg.com/jstodotxt/-/jstodotxt-1.0.0-alpha.3.tgz#ee4313bbfea94fb48503d7c530fbf2b130ecafb2"
integrity sha512-XGe6QfxnklhDKpSCgn2hNq2F9IXZZZf9sGzkEtLC6sVA7InVeaYXNiPcX1mKZ5Q2VpPY2siV1UlLfo5x6beP4Q==

"jsx-ast-utils@^2.4.1 || ^3.0.0":
version "3.3.5"
Expand Down

0 comments on commit b810555

Please sign in to comment.