Skip to content

Commit 7f14824

Browse files
authored
Merge pull request #164 from intri-in/development
v0.5.1
2 parents ce15c81 + ac040b8 commit 7f14824

File tree

11 files changed

+90
-33
lines changed

11 files changed

+90
-33
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v0.5.1
2+
- Fixed bug with recurring task.
3+
- Editing the task will now only set done status for the current recurrence id.
4+
- Add task component's input is now cleared with the task editor box opens
5+
- Fixed #159
6+
- Problem arose because of the type of any event created in other clients was not being recognised.
7+
18
v0.5.0
29
- Version Bump to 0.5.0
310
- Added Jotai for state management

COMMITMESSAGE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
- Added move to calendar option to Task Editor.
2-
- Before setting a default calendar in Event and Taskeditors, added a check to make sure it is a valid id.
3-
- UI Improvement to Home Page
1+
- Fixed bug with recurring task.
2+
- Editing the task will now only set done status for the current recurrence id.
3+
- Add task component's input is now cleared with the task editor box opens
4+
- Fixed #159
5+
- Problem arose because of the type of any event created in other clients was not being recognised.
6+
- Version bump to 0.5.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manage-my-damn-life-nextjs",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

src/components/common/AddTask/AddTaskFunctional.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ export function AddTaskFunctional(props) {
8787
const openTaskEditor = () =>{
8888

8989
let dataToPush = {...data}
90-
90+
9191
if(calDavObject && calDavObject.calendars_id){
9292
dataToPush.calendar_id= calDavObject.calendars_id
9393
}
9494
setTaskInputAtom(dataToPush)
95+
setNewTaskSummary("")
9596

9697
showTaskEditor(true)
9798

src/components/fullcalendar/CalendarViewWithStateManagement.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ export const CalendarViewWithStateManagement = ({ calendarAR }: { calendarAR: nu
174174
if (event.deleted == "1" || event.deleted == "TRUE") {
175175
continue
176176
}
177+
// console.log(event.type, event.calendar_events_id)
177178
if (event.type != "VTODO" && event.type != "VTIMEZONE") {
178179
const data = getParsedEvent(allEvents[i].events[j].data)
180+
// console.log("Parsed Event", data.summary, event.calendar_id, data)
179181
if (varNotEmpty(data) == false) {
180182
continue
181183
}

src/components/tasks/TaskEditorSupport/TaskEditorWithStateManagement.tsx

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { Datepicker } from "@/components/common/Datepicker/Datepicker"
3333
import { CalendarPicker } from "@/components/common/Calendarpicker"
3434
import { PRIMARY_COLOUR } from "@/config/style"
3535
import { moveEventModalInput, showMoveEventModal } from "stateStore/MoveEventStore"
36+
import next from "next/types"
3637

3738
const i18next = getI18nObject()
3839
export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailog, onServerResponse, closeEditor }: { input: TaskEditorInputType, onChange: Function, showDeleteDailog: Function, onServerResponse: Function, closeEditor: Function }) => {
@@ -75,6 +76,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
7576
const [category, setCategory] = useState<string[]>([])
7677
const [calendarDDLDisabled, setCalendarDDLDisabled] = useState(false)
7778
const [showMoveEventOption, setShowMoveEventOption]= useState(false)
79+
const [recurrenceObj, setRecurrenceObj] = useState<any>({})
7880
const changeDoneStatus = (isDone: boolean) => {
7981
if (isDone) {
8082
const completedDate = getISO8601Date(moment().toISOString())
@@ -131,7 +133,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
131133
// console.log("this.state.calendar_id at DDL", this.state.calendar_id)
132134
}
133135

134-
const checkInputForNewTask = async () => {
136+
const checkInputForNewTask = async (isRecurring?: boolean) => {
135137
if (input) {
136138
if (!input.id) {
137139
//Task is New.
@@ -189,7 +191,10 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
189191
//Process done info .
190192
if (input.taskDone) {
191193
setTaskDone(true)
192-
changeDoneStatus(true)
194+
// console.log("isRepeatingTask", isRepeatingTask)
195+
if(!isRecurring){
196+
changeDoneStatus(true)
197+
}
193198

194199
}
195200

@@ -253,7 +258,11 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
253258
}
254259
//Check and set repeating task parameters.
255260
setRrule(rruleToObject(parsedData["rrule"]))
261+
const isRecurring = parsedData["rrule"] ? true : false
256262
if (parsedData["rrule"]) {
263+
const parsedRecurrenceObj = new RecurrenceHelper(parsedData)
264+
// console.log(parsedRecurrenceObj)
265+
setRecurrenceObj(parsedRecurrenceObj)
257266
setIsRepeatingTask(true)
258267
}
259268
if (parsedData["priority"]) setPriority(parsedData["priority"])
@@ -266,7 +275,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
266275
}
267276
// console.log(parsedData)
268277
// getLabels(parsedData["category"])
269-
checkInputForNewTask()
278+
checkInputForNewTask(isRecurring)
270279
}
271280
}
272281

@@ -294,17 +303,43 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
294303
* Probably to set done for the new recurrenceid.
295304
* {TODO}: Figure it out
296305
*/
297-
let recurrenceObj = new RecurrenceHelper(parsedDataFromDexie)
298306
recurrences = _.cloneDeep(recurrenceObj.newRecurrence)
299-
if (Object.keys(recurrenceObj.newObj).length > 0 && recurrences) {
300-
const nextupKey = recurrenceObj.getNextUpKey()
301-
recurrences[nextupKey] = recurrenceObj.newObj[nextupKey]
307+
try{
308+
309+
if (Object.keys(recurrenceObj.newObj).length > 0 && recurrences) {
310+
const nextupKey = recurrenceObj.getNextUpKey()
311+
if(!nextupKey){
312+
toast.error("NextUpKey is empty!")
313+
return
314+
}
315+
recurrences[nextupKey] = recurrenceObj.newObj[nextupKey]
316+
const completedDate = getISO8601Date(moment().toISOString())
317+
/**
318+
* If done, set next repeating instance as completed.
319+
*/
320+
if(taskDone){
321+
recurrences[nextupKey]["completed"] = completedDate
322+
recurrences[nextupKey]["completion"] = "100"
323+
recurrences[nextupKey]["status"] = "COMPLETED"
324+
325+
}else{
326+
recurrences[nextupKey]["completed"] = ""
327+
recurrences[nextupKey]["completion"] = ""
328+
recurrences[nextupKey]["status"] = ""
329+
}
330+
331+
332+
if (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) == false || (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) && recurrences[nextupKey]["recurrenceid"] == "")) {
333+
recurrences[nextupKey]["recurrenceid"] = getISO8601Date(nextupKey)
334+
}
302335

303-
if (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) == false || (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) && recurrences[nextupKey]["recurrenceid"] == "")) {
304-
recurrences[nextupKey]["recurrenceid"] = getISO8601Date(nextupKey)
305-
}
306336

337+
}
338+
}catch(e){
339+
console.warn("Recurrence problem: "+summary, e, )
307340
}
341+
342+
308343
}
309344

310345
if (!summary) {
@@ -316,12 +351,9 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
316351
//dueDateToSave = fixDueDate(dueDate)
317352
dueDateToSave = moment(moment(dueDate).format(dateFullFormat)).toISOString()
318353
}
319-
console.log("due date to save", dueDate, taskStart)
354+
// console.log("due date to save", dueDate, taskStart)
320355
const valid = await checkifValid()
321356
if (valid) {
322-
if (taskDone) {
323-
324-
}
325357
setSubmitting(true)
326358
const todoData = { due: dueDate, start: taskStart, summary: summary, created: parsedDataFromDexie.created, completion: completion, completed: completed, status: status, uid: uid, categories: category, priority: priority, relatedto: relatedto, lastmodified: "", dtstamp: parsedDataFromDexie.dtstamp, description: description, rrule: rrule, recurrences: recurrences }
327359
const finalTodoData = await generateNewTaskObject(todoData, parsedDataFromDexie, unParsedData)
@@ -438,6 +470,11 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
438470

439471
}
440472
}
473+
474+
if(isRepeatingTask){
475+
//Check if the task can even be saved.
476+
477+
}
441478
return true
442479
}
443480

@@ -517,7 +554,9 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
517554

518555
const taskDoneChanged = (e) => {
519556
setTaskDone(e.target.checked)
520-
changeDoneStatus(e.target.checked)
557+
if(!isRepeatingTask){
558+
changeDoneStatus(e.target.checked)
559+
}
521560

522561
}
523562
const statusValueChanged = (e) => {
@@ -594,9 +633,8 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
594633
let repeatInfoMessage: JSX.Element = <></>
595634
let dueDateFixed = ""
596635
if (isRepeatingTask) {
597-
const repeatingInfo = new RecurrenceHelper(parsedDataFromDexie)
598-
dueDateFixed = moment(repeatingInfo.getNextDueDate()).format(dateFullFormat)
599-
repeatInfoMessage = (<Alert variant="warning">{i18next.t("REPEAT_TASK_MESSAGE") + moment(new Date(repeatingInfo.getNextDueDate())).format(dateFormat)}</Alert>)
636+
dueDateFixed = moment(recurrenceObj.getNextDueDate()).format(dateFullFormat)
637+
repeatInfoMessage = (<Alert variant="warning">{i18next.t("REPEAT_TASK_MESSAGE") + moment(recurrenceObj.getNextDueDate()).format(dateFormat)}</Alert>)
600638
}
601639

602640

src/config/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const VERSION_NUMBER = "0.5.0"
1+
export const VERSION_NUMBER = "0.5.1"
22
/*
33
* SYSTEM_DEFAULT_LABEL_PREFIX: Default prefix applied to all system generated labels like
44
* "My Day"

src/helpers/api/cal/caldav.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ export function checkifObjectisVTODO(data)
178178
try{
179179
const parsedData = ical.parseICS(data);
180180
for (let k in parsedData) {
181-
// console.log("parse Success")
182-
return parsedData[k].type
181+
// console.log("parse Success",k, parsedData[k])
182+
if(parsedData[k].type=="VTODO" || parsedData[k].type=="VEVENT") {
183+
return parsedData[k].type
184+
}
183185
}
184186

185187
}catch(e){
@@ -191,9 +193,9 @@ export function checkifObjectisVTODO(data)
191193
if(type=="")
192194
{
193195
const parsedData = parseICSWithICALJS(data, "VTODO");
194-
// console.log("parse Success", parsedData)
196+
console.log("parse Success", parsedData)
195197

196-
if(varNotEmpty(parsedData) && parsedData!={})
198+
if(varNotEmpty(parsedData) && ("summary" in parsedData) && parsedData!={})
197199
{
198200
return "VTODO"
199201
}else{

src/helpers/frontend/calendar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ export function returnEventType(data)
236236
try{
237237
const parsedData = ical.parseICS(data);
238238
for (let k in parsedData) {
239-
return parsedData[k].type
239+
240+
if(parsedData[k].type=="VTODO" || parsedData[k].type=="VEVENT") {
241+
return parsedData[k].type
242+
}
240243
}
241244

242245
}

src/helpers/frontend/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ export function getParsedEvent(dataInput)
255255
{
256256
for(const key in data)
257257
{
258+
// console.log("data[key]", data[key])
258259
if(data[key].type=="VEVENT")
259260
{
260261
return data[key]

src/pages/api/v2/calendars/events/fetch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ export default async function handler(req, res) {
4040
});
4141
if(calendarObjects && isValidResultArray(calendarObjects)){
4242
for(const i in calendarObjects){
43-
var type = checkifObjectisVTODO(calendarObjects[i])
44-
// console.log("type", type)
43+
const type = checkifObjectisVTODO(calendarObjects[i].data)
4544
calendarObjects[i]["type"]=type
4645
}
4746
}
48-
res.status(200).json({ version:2, success: true, data: { message: calendarObjects} })
47+
// console.log("calendarObjects", calendarObjects)
48+
return res.status(200).json({ version:2, success: true, data: { message: calendarObjects} })
4949

5050
}else{
5151
return res.status(401).json({ success: false, data: { message: 'ERROR_GENERIC'} })
5252

5353
}
5454

5555
}else{
56-
res.status(401).json({ success: false, data: { message: 'USER_DOESNT_HAVE_ACCESS'} })
56+
return res.status(401).json({ success: false, data: { message: 'USER_DOESNT_HAVE_ACCESS'} })
5757

5858
}
5959

0 commit comments

Comments
 (0)