mark-when / obsidian-plugin

Markwhen obsidian plugin
MIT License
143 stars 5 forks source link

New update adressing issue #7 and more #12

Open ulasfo opened 5 months ago

ulasfo commented 5 months ago

Added two new settings to the plugin: 1) toggle to open new .mw files under current viewed (file's) folder 2) toggle to add different views on context menu

2nd setting semi-adresses the 7th issue. I will be adding commands to command palette as a second smaller update.

Added a new command 'markwhen-create-template': Spawns a new file with all supported commands of markwhenview (file is on main folder of plugin markwhen.md, new file is created and populated with its contents, could be edited easily)

Fixed a bug where spam/fast clicking open new file on ribbon would cause file creation to throw an error due to name.

Bug details: Since the name is being generated on a format with 'DD-MM-YYYY HH.MM.SS', upon clicking new file under the same second would lead the second file throw an error file already exists. This would also mean that you could generate a new file once per second. Basic solution would be to check file existance and append a number at the end of the file. The problem arises when subsequent clicks would also check for subsequent files (think of Nth file under same second, it would need to check base file, 1st extra, 2nd extra... till the N). Since file existance checks are done on disk but not on cache/ram this was a resource hog and possible disk destroyer. I rewrote the file creation system with mutexes so that after file creation it checks for the time with Date.now() and adds a number at the end of the file. Since proper usage of mutexes, the concurrency of async functions are not broken. Since properly handling the time I did not check for file existance at all and it works fine on my machine but feel free to do testing and report any bugs.

ulasfo commented 5 months ago

well most of the code was done in a hurry thus comment/camelcasing issues had some problems but Im glad to work on the issues. So for the next update Id be adding commands for toggling the options and switching views while also adding an option switch for obsidian-like file names untitled(count) vs date.

in future maybe we can add option to add self hosted views (url) for markwhen and use real viewer as a fallback