Skip to content

Commit

Permalink
Merge pull request #12 from chinkan/feature/bugs-fix
Browse files Browse the repository at this point in the history
Feature/bugs fix
  • Loading branch information
chinkan authored Oct 24, 2024
2 parents c833e4d + 7c85438 commit 954e0db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function handleSummarize(request, sender, sendResponse) {
result.language
);

const summary = await provider.summarize(request.text, prompts.userPrompt, prompts.systemPrompt, defaultConfig.advancedSettings);
const summary = await provider.summarize(prompts.userPrompt, prompts.systemPrompt, defaultConfig.advancedSettings);

if (!summary || typeof summary.summary !== 'string') {
throw new Error('Invalid summary response from provider');
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "WizMuse",
"version": "0.7.0",
"version": "0.8.0",
"description": "WizMuse is a powerful web page summarization tool. Quickly extract core content from web pages to improve reading efficiency.",
"permissions": ["activeTab", "storage"],
"action": {
Expand Down
29 changes: 13 additions & 16 deletions pages/history.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// History Page
import { getStorageData, setStorageData, getAllStorageData } from '../utils/storage.js';
import { getStorageData, removeStorageData , getAllStorageData } from '../utils/storage.js';

export async function history() {
try {
Expand Down Expand Up @@ -32,10 +32,11 @@ export function initializeHistoryPage() {
getAllStorageData().then((items) => {
for (let key in items) {
if (key.startsWith('histories.')) {
const url = key.replace('histories.', '');
const data = items[key];
const row = elements.historyTable.insertRow();
row.innerHTML = `
<td><a href="${key}" target="_blank">${key}</a></td>
<td><a href="${url}" target="_blank">${url}</a></td>
<td>${data.title}</td>
<td>${new Date(data.timestamp).toLocaleString()}</td>
<td>
Expand All @@ -48,10 +49,10 @@ export function initializeHistoryPage() {
</div>
</td>
<td>
<button class="copy-btn action-btn" data-url="${key}" title="Copy Summary">
<button class="copy-btn action-btn" data-url="${url}" title="Copy Summary">
<i class="material-icons">content_copy</i>
</button>
<button class="delete-btn action-btn" data-url="${key}" title="Delete Summary">
<button class="delete-btn action-btn" data-url="${url}" title="Delete Summary">
<i class="material-icons">delete</i>
</button>
</td>
Expand All @@ -66,7 +67,6 @@ export function initializeHistoryPage() {
if (!row) return;
const url = row.cells[0].textContent;
const target = e.target.closest('button');

if (!target) {
showSummary(url);
} else if (target.classList.contains('copy-btn')) {
Expand All @@ -81,20 +81,20 @@ export function initializeHistoryPage() {
});

function showSummary(url) {
getStorageData(['histories']).then((result) => {
if (result.histories[url]) {
getStorageData([`histories.${url}`]).then((result) => {
if (result[`histories.${url}`]) {
elements.summaryContent.textContent =
result.histories[url].summary;
result[`histories.${url}`].summary;
elements.summaryModal.style.display = 'block';
}
});
}

function copySummary(url) {
getStorageData(['histories', 'llmConfigs', 'prompts']).then(
getStorageData([`histories.${url}`, 'llmConfigs', 'prompts']).then(
(result) => {
if (result.histories[url]) {
const summaryData = result.histories[url];
if (result[`histories.${url}`]) {
const summaryData = result[`histories.${url}`];
const promptName =
summaryData.promptName || 'Default Prompt';
const providerName = summaryData.providerName;
Expand Down Expand Up @@ -144,11 +144,8 @@ export function initializeHistoryPage() {

function deleteHistory(url, row) {
if (confirm('Are you sure you want to delete this history record?')) {
getStorageData(['histories']).then((result) => {
delete result.histories[url];
setStorageData({ histories: result.histories }).then(() => {
row.remove();
});
removeStorageData([`histories.${url}`]).then(() => {
row.remove();
});
}
}
Expand Down
12 changes: 5 additions & 7 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,18 @@ document.addEventListener('DOMContentLoaded', async function () {
setDefaultButton.className = 'set-default-button';
setDefaultButton.addEventListener('click', async () => {
const domainSettingsResult = await getStorageData([
'domainSettings',
`domainSettings.${currentDomain}`,
]);
let domainSettings = domainSettingsResult.domainSettings || {};
let domainSettings = domainSettingsResult[`domainSettings.${currentDomain}`] || {};

domainSettings[currentDomain] = {
domainSettings = {
selectedModelIndex: selectedModelIndex,
selectPromptIndex: selectPromptIndex,
llmConfigName: selectedModel.name,
promptName: selectedPrompt
? selectedPrompt.name
: 'Default Prompt',
promptName: selectedPrompt ? selectedPrompt.name : 'Default Prompt',
};

await setStorageData({ domainSettings: domainSettings });
await setStorageData({ [`domainSettings.${currentDomain}`]: domainSettings });

showTooltip(`Default set for ${currentDomain}`);
});
Expand Down

0 comments on commit 954e0db

Please sign in to comment.