andrewbrereton / obsidian-to-ical-plugin

This is a plugin for Obsidian that searches your vault for tasks that contain dates, and generates a calendar in iCal format that can be imported into your preferred calendar application.
MIT License
61 stars 15 forks source link

Fix: Replace Buffer with TextEncoder/TextDecoder for mobile comptability #94

Closed joseporiolcarne closed 2 months ago

joseporiolcarne commented 2 months ago
joseporiolcarne commented 2 months ago

This commit addresses the Uncaught (in promise) ReferenceError: Buffer is not defined error that occurs when using the plugin on mobile devices, specifically on Android. The error prevents the calendar from updating in the Gist or the file, and it does not appear on desktop environments. Issue Details:

What I found is that error occurs because Buffer is a Node.js-specific API, which is not available in environments like mobile versions of Obsidian This issue was observed on a Xiaomi 11 running Android, where the calendar would not update as expected. The error does not appear in desktop environments such as Windows 11 and Lubuntu 24.04, where Buffer is supported.

Solution:

Replaced the Buffer usage with TextEncoder and TextDecoder, which are compatible across all environments, including mobile versions of Obsidian.
I tested the changes on Android (Xiaomi 11), Windows 11, and Lubuntu 24.04, confirming that the calendar updates correctly across these platforms without triggering the error.