Skip to content

Commit

Permalink
fix: Projects without ids should be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Jun 27, 2022
1 parent 364aaa4 commit e7fffb1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/ModifyPomodoro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ModifyPomodoro: React.FC<{
</Radio.Group>
</Form.Item>
<Form.Item name="start" label="Start Time" rules={[{ required: true }]}>
<DatePicker showTime={{ format: 'HH:mm' }} />
<DatePicker showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm" />
</Form.Item>
<Form.Item name="length" label="Length" rules={[{ required: true }]}>
<InputNumber min={1} addonAfter="min" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/ModifySchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ const ModifySchedule: React.FC<{
<Input />
</Form.Item>
<Form.Item name="start" label="Start" rules={[{ required: true }]}>
<DatePicker showTime={showTime ? { format: 'HH:mm' } : false} />
<DatePicker showTime={showTime ? { format: 'HH:mm' } : false} format={ showTime ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD' } />
</Form.Item>
<Form.Item name="end" label="End" rules={[{ required: true }]}>
<DatePicker showTime={showTime ? { format: 'HH:mm' } : false} />
<DatePicker showTime={showTime ? { format: 'HH:mm' } : false} format={ showTime ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD' } />
</Form.Item>
<Form.Item name="isAllDay" label="All Day" rules={[{ required: true }]}>
<Radio.Group>
Expand Down
2 changes: 1 addition & 1 deletion src/components/PomodoroModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const PomodoroModal: React.FC<{
{ title: 'Full Tomato', dataIndex: 'isFull', render(value, record, index) {
return value ? '✅' : '❌'
}, },
{ title: 'Start', dataIndex: 'start', width: '200px', render: (value) => dayjs(value).format('YYYY-MM-DD HH:mm') },
{ title: 'Length', dataIndex: 'length', render: value => `${Math.ceil(value / 60)} min` },
{ title: 'Start', dataIndex: 'start', width: '200px', render: (value) => dayjs(value).format('YYYY-MM-DD HH:mm') },
Table.EXPAND_COLUMN,
{
title: 'Interruption',
Expand Down
1 change: 1 addition & 0 deletions src/constants/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const LOGSEQ_PROVIDE_COMMON_STYLE = `
border-radius: 4px;
padding: 1px 6px;
color: #222;
white-space: nowrap;
}
.dark .external-link[href^="#agenda-pomo://"] {
background-color: #1a543b;
Expand Down
3 changes: 2 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ async function renderApp(env: string) {
let defaultRoute = ''
const page = await logseq.Editor.getCurrentPage()
const { projectList = [] } = getInitalSettings()
if (isEnabledAgendaPage(page?.originalName) || projectList.some(project => project.id === page?.originalName)) defaultRoute = `project/${encodeURIComponent(page?.originalName)}`
if (projectList.some(project => Boolean(project.id) && project.id === page?.originalName)) defaultRoute = `project/${encodeURIComponent(page?.originalName)}`
console.log('[faiz:] === defaultRoute', defaultRoute)
ReactDOM.render(
<React.StrictMode>
{/* <App env={env} /> */}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Settings: React.FC<{
const [pageOptions, setPageOptions] = useState<any>([])

const [createCalendarModalVisible, setCreateCalendarModalVisible] = useState(false)
const initialValues = getInitalSettings()
const initialValues = getInitalSettings({ filterInvalideProject: false })
// TODO: 使用 only-write 减少重新渲染
const [, setProjectSchedules] = useAtom(projectSchedulesAtom)
const [, setSubscriptionSchedules] = useAtom(subscriptionSchedulesAtom)
Expand Down
5 changes: 4 additions & 1 deletion src/util/baseInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { ISchedule } from 'tui-calendar'
import { CALENDAR_THEME, DEFAULT_SETTINGS } from './constants'
import { ISettingsForm } from './type'

export const getInitalSettings = (): ISettingsForm => {
export const getInitalSettings = (params = { filterInvalideProject: true }): ISettingsForm => {
const { filterInvalideProject } = params
let logKey = DEFAULT_SETTINGS.logKey
const settingLogKey = logseq.settings?.logKey
if (settingLogKey) {
Expand Down Expand Up @@ -35,11 +36,13 @@ export const getInitalSettings = (): ISettingsForm => {
// },
// ...calendarList.slice(1),
// ]
const projectList = logseq.settings?.projectList || DEFAULT_SETTINGS.projectList
return {
...DEFAULT_SETTINGS,
...logseq.settings,
// calendarList,
logKey,
projectList: filterInvalideProject ? projectList?.filter(project => Boolean(project.id)) : projectList,
}
}

Expand Down

0 comments on commit e7fffb1

Please sign in to comment.