mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-10-31 14:34:00 +00:00 
			
		
		
		
	Fix: iCal integration use event data hash instead of uid (#2758)
This commit is contained in:
		
							parent
							
								
									a6e4786fc4
								
							
						
					
					
						commit
						99e1e3de3b
					
				| @ -7,6 +7,17 @@ import { RRule } from "rrule"; | ||||
| import useWidgetAPI from "../../../utils/proxy/use-widget-api"; | ||||
| import Error from "../../../components/services/widget/error"; | ||||
| 
 | ||||
| // https://gist.github.com/jlevy/c246006675becc446360a798e2b2d781 | ||||
| function simpleHash(str) { | ||||
|   /* eslint-disable no-plusplus, no-bitwise */ | ||||
|   let hash = 0; | ||||
|   for (let i = 0; i < str.length; i++) { | ||||
|     hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0; | ||||
|   } | ||||
|   return (hash >>> 0).toString(36); | ||||
|   /* eslint-disable no-plusplus, no-bitwise */ | ||||
| } | ||||
| 
 | ||||
| export default function Integration({ config, params, setEvents, hideErrors, timezone }) { | ||||
|   const { t } = useTranslation(); | ||||
|   const { data: icalData, error: icalError } = useWidgetAPI(config, config.name, { | ||||
| @ -47,7 +58,10 @@ export default function Integration({ config, params, setEvents, hideErrors, tim | ||||
|         const eventDate = timezone ? DateTime.fromJSDate(date, { zone: timezone }) : DateTime.fromJSDate(date); | ||||
| 
 | ||||
|         for (let j = 0; j < days; j += 1) { | ||||
|           eventsToAdd[`${event?.uid?.value}${i}${j}${type}`] = { | ||||
|           // See https://github.com/gethomepage/homepage/issues/2753 uid is not stable | ||||
|           // assumption is that the event is the same if the start, end and title are all the same | ||||
|           const hash = simpleHash(`${event?.dtstart?.value}${event?.dtend?.value}${title}${i}${j}${type}}`); | ||||
|           eventsToAdd[hash] = { | ||||
|             title, | ||||
|             date: eventDate.plus({ days: j }), | ||||
|             color: config?.color ?? "zinc", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 shamoon
						shamoon