From 7c9f0f6915642c5b9771a0fdc8543ae9685fc7dc Mon Sep 17 00:00:00 2001 From: aria Date: Fri, 27 Dec 2024 15:45:10 -0600 Subject: [PATCH] chore: code review changes --- README.md | 2 +- src/ImagePicker.ts | 2 +- src/ImagePickerSettings.tsx | 12 ++++++------ src/ImagePickerView.tsx | 2 +- src/client/ImagePickerView/ImagePickerView.tsx | 11 +++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e67702c..d92a7f1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 📷 Obsidian Image Picker +# 📷 Image Picker Image Picker is a _blazingly_ fast way to browse and find media in your Obsidian vault. It's **extremely performant**, automatically generating thumbnails and background indexing your vault for instant search results. diff --git a/src/ImagePicker.ts b/src/ImagePicker.ts index 5b1ffbe..1ad696b 100644 --- a/src/ImagePicker.ts +++ b/src/ImagePicker.ts @@ -38,7 +38,7 @@ export class ImagePicker extends Plugin { this.addSettingTab(new ImagePickerSettingTab(this.app, this)) - this.addRibbonIcon('image', 'Open Image Picker', async () => { + this.addRibbonIcon('image', 'Open image picker', async () => { this.activateView() }) diff --git a/src/ImagePickerSettings.tsx b/src/ImagePickerSettings.tsx index c6a6482..b3cfd19 100644 --- a/src/ImagePickerSettings.tsx +++ b/src/ImagePickerSettings.tsx @@ -23,13 +23,13 @@ export class ImagePickerSettingTab extends PluginSettingTab { // Input for selecting the image folder new Setting(containerEl) - .setName('Image Folder') + .setName('Image folder') .setDesc( 'Image picker will look for images in this folder and its subfolders, by default it will look in the root of the vault' ) .addText((text) => text - .setPlaceholder('Image Folder') + .setPlaceholder('Image folder') .setValue(this.plugin.settings.imageFolder) .onChange(async (value) => { this.plugin.settings.imageFolder = value || '' @@ -39,12 +39,12 @@ export class ImagePickerSettingTab extends PluginSettingTab { // Button for resetting the image index new Setting(containerEl) - .setName('Reset Image Index') + .setName('Reset image index') .setDesc( 'Clears the image index and rebuilds it from the image folder. Obsidian will reload immediately after. Please run this after changing the image folder.' ) .addButton((button) => - button.setButtonText('Reset Index').onClick(async () => { + button.setButtonText('Reset index').onClick(async () => { this.plugin.images = [] // delete the database and rebuild it await this.plugin.indexer.resetDB() @@ -57,7 +57,7 @@ export class ImagePickerSettingTab extends PluginSettingTab { // Toggle whether gifs are animated new Setting(containerEl) .setName('Animate GIFs') - .setDesc('Warning: large gifs can slow down or crash Obsidian') + .setDesc('Warning: large GIFs can slow down or crash Obsidian') .addToggle((toggle) => toggle .setValue(this.plugin.settings.animateGifs) @@ -69,7 +69,7 @@ export class ImagePickerSettingTab extends PluginSettingTab { // Toggle whether to log debug messages new Setting(containerEl) - .setName('Debug Mode') + .setName('Debug mode') .setDesc('Log debug messages to the console') .addToggle((toggle) => toggle diff --git a/src/ImagePickerView.tsx b/src/ImagePickerView.tsx index 11ead39..3f31ae3 100644 --- a/src/ImagePickerView.tsx +++ b/src/ImagePickerView.tsx @@ -24,7 +24,7 @@ export class ImagePickerView extends ItemView { } getDisplayText() { - return 'Image Picker' + return 'Image picker' } getIcon(): string { diff --git a/src/client/ImagePickerView/ImagePickerView.tsx b/src/client/ImagePickerView/ImagePickerView.tsx index ead8699..7b3c107 100644 --- a/src/client/ImagePickerView/ImagePickerView.tsx +++ b/src/client/ImagePickerView/ImagePickerView.tsx @@ -1,6 +1,6 @@ import { debounce, isEqual, throttle, truncate } from 'lodash' import { useEffect, useState, useRef, useCallback, useMemo } from 'react' -import { Notice, TFile } from 'obsidian' +import { Notice, Platform, TFile } from 'obsidian' import { MOBILE_MAX_FILE_SIZE, @@ -24,7 +24,6 @@ import { Pagination } from './Pagination' import { Search } from './Search' export const ImagePickerView = () => { - const IS_MOBILE = useRef(document.querySelector('.is-mobile') !== null) const plugin = usePlugin() const app = useApp() const images = useFiles() @@ -137,7 +136,7 @@ export const ImagePickerView = () => { if ( getSizeInKb(file.stat.size) > - (IS_MOBILE.current ? MOBILE_MAX_FILE_SIZE : DESKTOP_MAX_FILE_SIZE) + (Platform.isMobile ? MOBILE_MAX_FILE_SIZE : DESKTOP_MAX_FILE_SIZE) ) return false @@ -293,9 +292,9 @@ export const ImagePickerView = () => { length: 30, })} - - - + + +