derekantrican / GAS-ICS-Sync

A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
GNU General Public License v3.0
1.5k stars 192 forks source link

Allow alternate calendar name to be prepended to title #366

Open shadowjig opened 11 months ago

shadowjig commented 11 months ago

Is your feature request related to a problem? Please describe.

Instead of prepending the Calendar name to the title of each event (enabled by addCalToTitle), allow us to enter an alternate calendar name in the sourceCalendars array.

For example: var sourceCalendars = [ ["<some ical URL>", "Test Calendar", "11", "Alternate Calendar Name"] ];

Describe the solution you'd like

Enter a fourth option in the sourceCalendars array for a given ical URL. That fourth option would be prepended to each event that's added to the target calendar from the applicable source calendar.

Additional context

No response

Lonestarjeepin commented 10 months ago

If you use #372, it allows you to define an alternate calendar name just like you are looking for (in fact, it is required). Then you will just need to modify the existing addCalToTitle (see below - I put the sourceCalendarName at the end, but you can move it back to the beginning if you want). HOWEVER, a word of warning... #372 works quite differently than the current Master branch. Instead of grouping all source calendars with their corresponding target calendar, this code loops through each source calendar and processes it individually. I'd recommend you delete all calendars entries in your current calendars (you can replace your ics URLs with this empty calendar URL and run it - https://pastebin.com/raw/mEWyU5hV) that were created by GAS-ICS-Sync before you run this the first time. If you don't, it will create duplicate entries (it's because I had to modify the fromGAS part of the code to resolve overwrite conflicts). You can ignore the SyncDelay parts of this if they aren't important to you.

if (addCalToTitle && event.hasProperty('parentCal')){ //var calName = event.getFirstPropertyValue('parentCal'); newEvent.summary = newEvent.summary + " (" + sourceCalendarName + ")"; }

moritz-schuessler commented 9 months ago

I changed to code for myself. It wasn't that much work. Rather then using the array for Optional Arguments in the settings, i would propose using an object for these optional Arguments.

["https://p24-calendars.icloud.com/holidays/us_en.ics", "US Holidays", {
    colorId: '1',
    calendarName: 'New Name'
}]

This change would allow to make future development easier and the settings will be easier to understand. I will clean up my code and make a PR. Even if it wont be used, I think that this could be done similar in a potential refactor #311.