Skip to content

Commit

Permalink
fix: update subscription config error when subscription is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Mar 12, 2022
1 parent e088cc3 commit 2c9ab2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ const App: React.FC<{ env: string }> = ({ env }) => {
}
const onSettingChange = (values: ISettingsForm) => {
logseq.updateSettings({calendarList: 1, subscriptionList: 1})
logseq.updateSettings(values)
// ensure subscription list is array
logseq.updateSettings({subscriptionList: [], ...values})
if (values.weekStartDay !== logseq.settings?.weekStartDay) {
calendarRef.current?.setOptions({
week: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const Settings: React.FC<{
<Form.Item name={[field.name, 'id']} noStyle rules={[{ required: true }]}>
<Input placeholder="Calendar ID" style={{ width: '100px' }} />
</Form.Item>
<Form.Item name={[field.name, 'url']} noStyle rules={[{ required: true }]}>
<Form.Item name={[field.name, 'url']} noStyle rules={[{ required: true, type: 'url' }]}>
<Input placeholder="Url" style={{ width: '100px' }} />
</Form.Item>
<Form.Item name={[field.name, 'bgColor']} noStyle rules={[{ required: true }]}>
Expand Down
2 changes: 1 addition & 1 deletion src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ export const managePluginTheme = async () => {
* get ical data
*/
export const getSubCalendarSchedules = async (subscriptionCalendarList: ISettingsForm['subscriptionList'], defaultDuration?: ISettingsForm['defaultDuration']) => {
if (!Array.isArray(subscriptionCalendarList)) return []
const enabledCalendarList = subscriptionCalendarList?.filter(calendar => calendar.enabled)
if (!enabledCalendarList?.length) return []

const resList = await Promise.allSettled(enabledCalendarList.map(calendar => axios(calendar.url)))
// const resList = await Promise.allSettled(subscriptionCalendarList.map(calendar => ical.fromURL(calendar.url)))

let schedules = []
resList.forEach((res, index) => {
Expand Down

0 comments on commit 2c9ab2d

Please sign in to comment.