sync: Redis caching for browse/skill API, progress bar on search, default sort by stars
- Add Redis caching to browse search results and skill detail API - Show progress bar on homepage search - Default sort to stars Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -272,6 +272,10 @@ export function SearchBar({ placeholder, defaultValue = '' }: SearchBarProps) {
|
||||
|
||||
if (searchQuery) {
|
||||
params.set('q', searchQuery);
|
||||
// Default to sorting by stars when searching
|
||||
if (!params.get('sort')) {
|
||||
params.set('sort', 'stars');
|
||||
}
|
||||
} else {
|
||||
params.delete('q');
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ export function HeroSearch({ placeholder, locale }: HeroSearchProps) {
|
||||
|
||||
const handleSubmit = (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
window.dispatchEvent(new Event('progressbar:start'));
|
||||
if (query.trim()) {
|
||||
router.push(`/${locale}/browse?q=${encodeURIComponent(query.trim())}`);
|
||||
router.push(`/${locale}/browse?q=${encodeURIComponent(query.trim())}&sort=stars`);
|
||||
} else {
|
||||
router.push(`/${locale}/browse`);
|
||||
}
|
||||
|
||||
@@ -121,12 +121,19 @@ export function ProgressBar() {
|
||||
const handlePopState = () => onUrlChange();
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
|
||||
// 4. Custom event for programmatic navigation (e.g. form submits with router.push)
|
||||
const handleManualStart = () => {
|
||||
if (!isRunningRef.current) start();
|
||||
};
|
||||
window.addEventListener('progressbar:start', handleManualStart);
|
||||
|
||||
return () => {
|
||||
clearTimers();
|
||||
document.removeEventListener('click', handleClick, true);
|
||||
history.pushState = origPushState;
|
||||
history.replaceState = origReplaceState;
|
||||
window.removeEventListener('popstate', handlePopState);
|
||||
window.removeEventListener('progressbar:start', handleManualStart);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user