Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/extension/ExtensionStateManger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as vscode from "vscode";

import { COLLECTION } from "./constants";
import { filterDuplicatesFromObject } from "./utils";
import { IUserRequestSidebarState } from "./utils/type";

class ExtentionStateManager {
Expand Down Expand Up @@ -32,38 +31,6 @@ class ExtentionStateManager {
await this.context.globalState.update(state, history);
}

async updateExtensionContext(state: string, id: string, status?: string) {
const currentTime = new Date().getTime();
const globalHistoryState: IUserRequestSidebarState[] | undefined =
this.context.globalState.get(state);
const globalFavoritesState: IUserRequestSidebarState[] | undefined =
this.context.globalState.get(COLLECTION.FAVORITES_COLLECTION);

if (!globalHistoryState || !globalFavoritesState) return;

globalHistoryState.map(
(history) =>
history.id === id &&
((history.isUserFavorite = !history.isUserFavorite),
(history.favoritedTime = currentTime)),
);

await this.context.globalState.update(state, [...globalHistoryState]);

if (status) {
const duplicateFilteredUserFavoriteCollection =
filterDuplicatesFromObject(
globalHistoryState,
globalFavoritesState,
id,
);

await this.context.globalState.update(COLLECTION.FAVORITES_COLLECTION, [
...duplicateFilteredUserFavoriteCollection,
]);
}
}

async deleteExtensionContext(targetExtensionContext: string, id?: string) {
const targetGlobalState: IUserRequestSidebarState[] | undefined =
this.context.globalState.get(targetExtensionContext);
Expand Down
9 changes: 0 additions & 9 deletions src/extension/MainWebViewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class MainWebViewPanel {
headers,
responseType,
requestedTime,
favoritedTime: null,
isUserFavorite: false,
id: requestId,
requestObject,
};
Expand All @@ -177,7 +175,6 @@ class MainWebViewPanel {
// Update sidebar
this.sidebarWebViewPanel.postMainWebViewPanelMessage(
this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION),
this.stateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION),
);

} catch (error) {
Expand Down Expand Up @@ -269,8 +266,6 @@ class MainWebViewPanel {
{
...axiosConfiguration,
requestedTime,
favoritedTime: null,
isUserFavorite: false,
id: uuidv4(),
requestObject,
},
Expand All @@ -287,8 +282,6 @@ class MainWebViewPanel {
{
...axiosConfiguration,
requestedTime,
favoritedTime: null,
isUserFavorite: false,
id: uuidv4(),
requestObject,
},
Expand All @@ -302,12 +295,10 @@ class MainWebViewPanel {
if (this.mainPanel) {
console.log(
this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION),
this.stateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION),
);
this.mainPanel.webview.postMessage(responseObject);
this.sidebarWebViewPanel.postMainWebViewPanelMessage(
this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION),
this.stateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION),
);
}
}
Expand Down
76 changes: 0 additions & 76 deletions src/extension/SidebarWebViewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,11 @@ class SidebarWebViewPanel {
history: this.stateManager.getExtensionContext(
COLLECTION.HISTORY_COLLECTION,
),
favorites: this.stateManager.getExtensionContext(
COLLECTION.FAVORITES_COLLECTION,
),
collections: collections,
});

console.log('Initial sidebar data sent:', {
history: this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION),
favorites: this.stateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION),
collections: collections
});

Expand All @@ -73,9 +69,6 @@ class SidebarWebViewPanel {
userHistoryData: {
userRequestHistory: IUserRequestSidebarState[] | undefined;
},
userFavoritesData: {
userRequestHistory: IUserRequestSidebarState[] | undefined;
},
) {
if (!this.sidebarWebview) {
console.log('Sidebar webview not available, skipping update');
Expand All @@ -87,14 +80,12 @@ class SidebarWebViewPanel {

console.log('Updating sidebar with data:', {
history: userHistoryData,
favorites: userFavoritesData,
collections: collections
});

this.sidebarWebview.webview.postMessage({
messageCategory: CATEGORY.COLLECTION_DATA,
history: userHistoryData,
favorites: userFavoritesData,
collections: collections,
});
}
Expand All @@ -114,74 +105,7 @@ class SidebarWebViewPanel {
}) => {
if (command === COMMAND.START_APP) {
vscode.commands.executeCommand(COMMAND.MAIN_WEB_VIEW_PANEL);
} else if (command === COMMAND.ADD_TO_FAVORITES) {
// Get the request from history
const historyData = this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION);
const historyItem = historyData?.userRequestHistory?.find((item: any) => item.id === id);

if (historyItem) {
// Mark as favorite in history
const updatedItem = {
...historyItem,
isUserFavorite: true,
favoritedTime: new Date().getTime(),
};

// Add to favorites collection
const favoritesData = this.stateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION);
const favorites = favoritesData?.userRequestHistory || [];

await this.stateManager.addExtensionContext(COLLECTION.FAVORITES_COLLECTION, {
history: [updatedItem, ...favorites],
});

// Update history to mark as favorite
const history = historyData?.userRequestHistory || [];
const updatedHistory = history.map((item: any) =>
item.id === id ? updatedItem : item
);

await this.stateManager.addExtensionContext(COLLECTION.HISTORY_COLLECTION, {
history: updatedHistory,
});
}
} else if (command === COMMAND.REMOVE_FROM_FAVORITES) {
// Get the request from history
const historyData = this.stateManager.getExtensionContext(COLLECTION.HISTORY_COLLECTION);
const historyItem = historyData?.userRequestHistory?.find((item: any) => item.id === id);

if (historyItem) {
// Mark as not favorite in history
const updatedItem = {
...historyItem,
isUserFavorite: false,
favoritedTime: null,
};

// Update history
const history = historyData?.userRequestHistory || [];
const updatedHistory = history.map((item: any) =>
item.id === id ? updatedItem : item
);

await this.stateManager.addExtensionContext(COLLECTION.HISTORY_COLLECTION, {
history: updatedHistory,
});
}

// Remove from favorites collection
await this.stateManager.deleteExtensionContext(
COLLECTION.FAVORITES_COLLECTION,
id,
);
} else if (command === COMMAND.DELETE) {
if (target === COLLECTION.FAVORITES_COLLECTION) {
await this.stateManager.updateExtensionContext(
COLLECTION.HISTORY_COLLECTION,
id,
);
}

await this.stateManager.deleteExtensionContext(target, id);
} else if (command === COMMAND.DELETE_ALL_COLLECTION) {
const answer = await vscode.window.showWarningMessage(
Expand Down
3 changes: 0 additions & 3 deletions src/extension/constants/collection.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const COLLECTION = {
FAVORITES_COLLECTION: "userFavorites",
HISTORY_COLLECTION: "userRequestHistory",
COLLECTION_REQUEST: "Collection Request",
FILTERABLE_OBJECT_KEY: [
"favoritedTime",
"id",
"requestedTime",
"isUserFavorite",
],
};

Expand Down
2 changes: 0 additions & 2 deletions src/extension/constants/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ const COMMAND = {
DELETE: "Delete",
START_APP: "Start App",
ALERT_COPY: "Alert Copy",
ADD_TO_FAVORITES: "Add to favorites",
MAIN_WEB_VIEW_PANEL: "opencall.newRequest",
SIDEBAR_WEB_VIEW_PANEL: "opencall.collectionMenu",
REMOVE_FROM_FAVORITES: "Remove from favorites",
DELETE_ALL_COLLECTION: "Delete all collection",
};

Expand Down
6 changes: 0 additions & 6 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ export async function activate(context: vscode.ExtensionContext) {
});
}

if (!StateManager.getExtensionContext(COLLECTION.FAVORITES_COLLECTION)) {
await StateManager.addExtensionContext(COLLECTION.FAVORITES_COLLECTION, {
history: [],
});
}

vscode.window.showInformationMessage(MESSAGE.WELCOME_MESSAGE);

// Collections are now shown in the webview sidebar tabs
Expand Down
31 changes: 0 additions & 31 deletions src/extension/utils/filterDuplicatesFromObject.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/extension/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as filterDuplicatesFromObject } from "./filterDuplicatesFromObject";
export { default as filterObjectKey } from "./filterObjectKey";
export { default as generateArrayObjectFromData } from "./generateArrayObjectFromData";
export { default as generateResponseObject } from "./generateResponseObject";
Expand Down
2 changes: 0 additions & 2 deletions src/extension/utils/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export interface IUserRequestSidebarState {
headers: Headers;
responseType: string;
requestedTime: number;
favoritedTime: number | null;
isUserFavorite: boolean;
id: string;
requestObject: RequestObject;
}
Expand Down
31 changes: 0 additions & 31 deletions src/utils/filterDuplicatesFromObject.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as filterDuplicatesFromObject } from "./filterDuplicatesFromObject";
export { default as filterObjectKey } from "./filterObjectKey";
export { default as generateArrayObjectFromData } from "./generateArrayObjectFromData";
export { default as generateResponseObject } from "./generateResponseObject";
Expand Down
2 changes: 0 additions & 2 deletions src/utils/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export interface IUserRequestSidebarState {
headers: Headers;
responseType: string;
requestedTime: number;
favoritedTime: number | null;
isUserFavorite: boolean;
id: string;
requestObject: RequestObject;
}
Expand Down
4 changes: 0 additions & 4 deletions webview/components/MoreInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const MoreInformationWrapper = styled.div`
opacity: 0.45;
}
}

.favorite {
fill: var(--vscode-errorForeground, #f48771);
}
`;

export default MoreInformation;
2 changes: 1 addition & 1 deletion webview/constants/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const OPTION = {
READ_ONLY_TRUE_OPTION: { readOnly: true, lineNumbers: "on" },
READ_ONLY_FALSE_OPTION: { readOnly: false, lineNumbers: "on" },
LINE_NUMBER_OPTION: { readOnly: true, lineNumbers: "off" },
SIDEBAR_MENU_OPTIONS: ["Collections", "History", "Favorites"],
SIDEBAR_MENU_OPTIONS: ["Collections", "History"],
CODE_SNIPPET_OPTIONS: [
{
key: "c",
Expand Down
4 changes: 0 additions & 4 deletions webview/constants/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ const SIDEBAR = {
DELETE: "Delete",
HISTORY: "History",
START_APP: "Start App",
FAVORITES: "Favorites",
COLLECTIONS: "Collections",
COLLECTION_DATA: "Collection Data",
ADD_TO_FAVORITES: "Add to favorites",
DELETE_COMPLETE: "Deletion Complete",
USER_FAVORITES_COLLECTION: "userFavorites",
DELETE_ALL_COLLECTION: "Delete all collection",
REMOVE_FROM_FAVORITES: "Remove from favorites",
USER_REQUEST_HISTORY_COLLECTION: "userRequestHistory",
};

Expand Down
Loading