diff --git a/client.js b/client.js
index 551972c..e10cdbc 100644
--- a/client.js
+++ b/client.js
@@ -4354,20 +4354,54 @@ try {
var q = query.trim();
try {
var list = getRecentSearches();
+ // Remove previous occurrence of the exact term (case-insensitive) and bubble it to the very top (#1)
list = list.filter(function (item) {
return item.toLowerCase() !== q.toLowerCase();
});
list.unshift(q);
- if (list.length > 12) list = list.slice(0, 12);
+ if (list.length > 20) list = list.slice(0, 20);
localStorage.setItem('yaktube_recent_searches', JSON.stringify(list));
} catch (e) {}
// If user is logged in and sync is active, sync with YakNet account
if (isAccountSyncEnabled()) {
- callCloudSearchHistory('POST', '', { query: q, device_name: 'YakTube Web' });
+ callCloudSearchHistory('POST', '', { query: q, device_name: 'YakTube Web' }, function (data) {
+ if (data && data.status === 'success' && Array.isArray(data.history) && data.history.length > 0) {
+ localStorage.setItem('yaktube_recent_searches', JSON.stringify(data.history));
+ }
+ });
}
}
+ function deleteRecentSearch(targetQuery) {
+ if (!targetQuery) return;
+ var q = targetQuery.trim();
+ try {
+ var list = getRecentSearches();
+ list = list.filter(function (item) {
+ return item.toLowerCase() !== q.toLowerCase();
+ });
+ localStorage.setItem('yaktube_recent_searches', JSON.stringify(list));
+ } catch (e) {}
+
+ if (isAccountSyncEnabled()) {
+ callCloudSearchHistory('DELETE', '?query=' + encodeURIComponent(q), { query: q }, function (data) {
+ if (data && data.status === 'success' && Array.isArray(data.history)) {
+ localStorage.setItem('yaktube_recent_searches', JSON.stringify(data.history));
+ }
+ });
+ }
+
+ var modal = document.getElementById('yaktube-full-search-modal');
+ var filterVal = '';
+ if (modal) {
+ var inp = modal.querySelector('#yaktube-modal-input');
+ if (inp) filterVal = inp.value;
+ }
+ renderDynamicSearchChips(filterVal);
+ announce('"' + q + '" araması geçmişten silindi.');
+ }
+
function clearRecentSearches() {
try {
localStorage.removeItem('yaktube_recent_searches');
@@ -4406,7 +4440,7 @@ try {
captureUrlSearchQuery();
window.addEventListener('popstate', captureUrlSearchQuery);
- function renderDynamicSearchChips() {
+ function renderDynamicSearchChips(filterText) {
var modal = document.getElementById('yaktube-full-search-modal');
if (!modal) return;
@@ -4416,12 +4450,28 @@ try {
var recent = getRecentSearches();
var loggedIn = isUserLoggedIn();
var syncEnabled = isAccountSyncEnabled();
+ var filter = (filterText || '').trim().toLowerCase();
+
+ var displayedRecent = recent;
+ var displayedPopular = popularTrendingQueries;
+
+ if (filter.length > 0) {
+ displayedRecent = recent.filter(function (term) {
+ return term.toLowerCase().includes(filter);
+ });
+ displayedPopular = popularTrendingQueries.filter(function (item) {
+ return item.q.toLowerCase().includes(filter) || item.title.toLowerCase().includes(filter);
+ });
+ }
+
var html = '';
// 1. Recent searches section
html +=
'
' +
- '
🕒 Son Aramalarınız
' +
+ '
🕒 ' +
+ (filter.length > 0 ? 'Eşleşen Son Aramalarınız' : 'Son Aramalarınız') +
+ '
' +
'
';
if (loggedIn) {
@@ -4448,52 +4498,82 @@ try {
'🔒 Bu Cihazda';
}
- if (recent.length > 0) {
+ if (recent.length > 0 && filter.length === 0) {
html +=
- '';
+ '';
}
html += '
';
- if (recent.length > 0) {
+ if (displayedRecent.length > 0) {
html += '';
- recent.forEach(function (term) {
+ displayedRecent.forEach(function (term) {
var safeTerm = term.replace(/"/g, '"');
html +=
- '
';
+ });
+ html += '';
+ } else if (filter.length > 0) {
+ html +=
+ 'Geçmişte "' +
+ filter.replace(/"/g, '"') +
+ '" ile eşleşen kayıt bulunamadı.
';
+ }
+
+ // 2. Popular & Trending searches section
+ if (displayedPopular.length > 0) {
+ html +=
+ '🔥 ' +
+ (filter.length > 0 ? 'Önerilen Aramalar' : 'Hızlı ve Popüler Aramalar') +
+ '
' +
+ '';
+
+ displayedPopular.forEach(function (item) {
+ var safeQ = item.q.replace(/"/g, '"');
+ html +=
+ '' +
+ item.title +
'';
});
html += '
';
}
- // 2. Popular & Trending searches section
- html +=
- '🔥 Hızlı ve Popüler Aramalar
' +
- '';
-
- popularTrendingQueries.forEach(function (item) {
- var safeQ = item.q.replace(/"/g, '"');
- html +=
- '' +
- item.title +
- '';
- });
- html += '
';
-
container.innerHTML = html;
// Attach click events
+ container.querySelectorAll('.yaktube-recent-chip-delete').forEach(function (delBtn) {
+ delBtn.addEventListener('click', function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ var delTerm = delBtn.getAttribute('data-delete-query');
+ deleteRecentSearch(delTerm);
+ });
+ });
+
container.querySelectorAll('.yaktube-modal-chip').forEach(function (chip) {
- chip.addEventListener('click', function () {
+ chip.addEventListener('click', function (e) {
+ if (e.target && e.target.classList.contains('yaktube-recent-chip-delete')) {
+ return;
+ }
var query = chip.getAttribute('data-query');
var inp = modal.querySelector('#yaktube-modal-input');
if (inp) inp.value = query;
@@ -4576,19 +4656,22 @@ try {
var voiceBtn = modal.querySelector('#yaktube-modal-voice-btn');
var micPulseBtn = modal.querySelector('#yaktube-modal-mic-pulse');
- // Input typing & clear
+ // Input typing & live search history filtering
inp.addEventListener('input', function () {
- if (inp.value && inp.value.trim().length > 0) {
+ var val = (inp.value || '').trim();
+ if (val.length > 0) {
clearBtn.style.display = 'inline-flex';
} else {
clearBtn.style.display = 'none';
}
+ renderDynamicSearchChips(val);
});
clearBtn.addEventListener('click', function () {
inp.value = '';
clearBtn.style.display = 'none';
inp.focus();
+ renderDynamicSearchChips('');
announce('Arama metni temizlendi.');
});
@@ -4632,14 +4715,6 @@ try {
}
});
- // Chips click
- modal.querySelectorAll('.yaktube-modal-chip').forEach(function (chip) {
- chip.addEventListener('click', function () {
- var query = chip.getAttribute('data-query');
- executeSearch(query);
- });
- });
-
// Voice button click
voiceBtn.addEventListener('click', function () {
toggleVoiceInsideModal();
diff --git a/main.js b/main.js
index 4b9de04..873c177 100644
--- a/main.js
+++ b/main.js
@@ -1340,13 +1340,20 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
if (q && q.length >= 2) {
const filtered = currentList.filter(item => String(item).toLowerCase() !== q.toLowerCase());
filtered.unshift(q);
- store[userKey] = filtered.slice(0, 12);
+ store[userKey] = filtered.slice(0, 20);
writeHistoryStore(store);
}
return res.json({ status: 'success', history: store[userKey] || currentList });
}
if (req.method === 'DELETE') {
+ const target = ((req.body && req.body.query) || (req.query && req.query.query) || '').trim();
+ if (target) {
+ const filtered = currentList.filter(item => String(item).toLowerCase() !== target.toLowerCase());
+ store[userKey] = filtered;
+ writeHistoryStore(store);
+ return res.json({ status: 'success', history: filtered });
+ }
delete store[userKey];
writeHistoryStore(store);
return res.json({ status: 'success', history: [] });
diff --git a/package.json b/package.json
index 9310ea8..ee38e91 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "peertube-plugin-yaktube-ondemand",
- "version": "1.6.7",
+ "version": "1.6.8",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
"main": "main.js",
"library": "./main.js",
diff --git a/style.css b/style.css
index 82dda68..a194543 100644
--- a/style.css
+++ b/style.css
@@ -810,6 +810,42 @@ my-search-typeahead,
transform: translateY(-1px) !important;
}
+.yaktube-modal-chip.yaktube-recent-chip {
+ padding: 6px 10px 6px 14px !important;
+ gap: 8px !important;
+}
+
+.yaktube-recent-chip-text {
+ cursor: pointer !important;
+ display: inline-flex !important;
+ align-items: center !important;
+}
+
+.yaktube-recent-chip-delete {
+ background: rgba(255, 255, 255, 0.08) !important;
+ border: none !important;
+ color: #94a3b8 !important;
+ font-size: 11px !important;
+ font-weight: 700 !important;
+ line-height: 1 !important;
+ cursor: pointer !important;
+ width: 18px !important;
+ height: 18px !important;
+ border-radius: 50% !important;
+ display: inline-flex !important;
+ align-items: center !important;
+ justify-content: center !important;
+ transition: all 0.2s ease !important;
+ margin-left: 2px !important;
+ padding: 0 !important;
+}
+
+.yaktube-recent-chip-delete:hover {
+ background: rgba(239, 68, 68, 0.35) !important;
+ color: #ff6b6b !important;
+ transform: scale(1.15) !important;
+}
+
.yaktube-modal-hint-footer {
display: flex !important;
justify-content: space-between !important;