From 3ae32601cac0f9b4fb0cfb51273ad6039da45586 Mon Sep 17 00:00:00 2001 From: Meichen Dong <97109672+meichend@users.noreply.github.com> Date: Fri, 22 Jul 2022 11:31:10 -0400 Subject: [PATCH 1/5] COD-1266 Correct notification count in VS Code bar (#463) * Use status bar update message to pass notifications to status bar * oops --- .../extension/statusBarUpdate.command.ts | 25 +++++++++++++++++++ .../deleteNotification.command.ts | 2 -- .../deleteNotifications.command.ts | 2 -- .../markAllNotificationRead.command.ts | 2 -- .../updateNotification.command.ts | 2 -- codex-vscode/src/globals.ts | 2 ++ .../helpers/handlers/pusherEvent.handler.ts | 4 +-- .../webviewOutgoingMessage.handler.ts | 16 ++++++++++++ .../src/helpers/notifications.helper.ts | 12 ++++----- .../webview/webviewOutgoingMessage.model.ts | 9 ++++++- codex-webview/src/globals.ts | 2 ++ .../shared/webviewIncomingMessage.model.ts | 8 +++++- .../webview/webviewOutgoingMessage.model.ts | 9 ++++++- codex-webview/src/views/Root.svelte | 11 +++++++- 14 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 codex-vscode/src/commands/extension/statusBarUpdate.command.ts diff --git a/codex-vscode/src/commands/extension/statusBarUpdate.command.ts b/codex-vscode/src/commands/extension/statusBarUpdate.command.ts new file mode 100644 index 00000000..cc630cf9 --- /dev/null +++ b/codex-vscode/src/commands/extension/statusBarUpdate.command.ts @@ -0,0 +1,25 @@ +import type { Notification } from "@usecodex/common-library"; +import { MESSAGE_TYPES } from "../../globals"; +import { handleSetStatusBarMessage, StatusBarData } from "../../helpers/notifications.helper"; +import BaseCommand from "../base/base.command"; +import { ExecutedCommandResponse } from "../base/command"; + +export default class StatusBarUpdateCommand extends BaseCommand { + public messageType: MESSAGE_TYPES = MESSAGE_TYPES.statusBarUpdate; + public statusData: StatusBarData; + + constructor(statusData: StatusBarData) { + super(); + this.statusData = statusData; + } + + async execute(): Promise> { + try { + handleSetStatusBarMessage(this.statusData); + return this.formatSuccessResponse(); + } catch (err) { + this.logError(err); + return this.formatErrorResponse(); + } + } +} diff --git a/codex-vscode/src/commands/notification/deleteNotification.command.ts b/codex-vscode/src/commands/notification/deleteNotification.command.ts index 069d2f83..01be6065 100644 --- a/codex-vscode/src/commands/notification/deleteNotification.command.ts +++ b/codex-vscode/src/commands/notification/deleteNotification.command.ts @@ -1,6 +1,5 @@ import type { Notification } from "@usecodex/common-library"; import { MESSAGE_TYPES } from "../../globals"; -import { handleStatusBarUpdate } from "../../helpers/notifications.helper"; import { UserService } from "../../services/user.service"; import BaseCommand from "../base/base.command"; import { ExecutedCommandResponse } from "../base/command"; @@ -18,7 +17,6 @@ export default class DeleteNotificationCommand extends BaseCommand async execute(): Promise> { try { await UserService.getInstance().getNotificationService().delete(this.notification.id); - await handleStatusBarUpdate(); this.logAnalytics(new ContentEventAnalyticsData(this.notification)); return this.formatSuccessResponse(this.notification); diff --git a/codex-vscode/src/commands/notification/deleteNotifications.command.ts b/codex-vscode/src/commands/notification/deleteNotifications.command.ts index 6f6a076c..748a8552 100644 --- a/codex-vscode/src/commands/notification/deleteNotifications.command.ts +++ b/codex-vscode/src/commands/notification/deleteNotifications.command.ts @@ -1,6 +1,5 @@ import type { Notification } from "@usecodex/common-library"; import { MESSAGE_TYPES } from "../../globals"; -import { handleStatusBarUpdate } from "../../helpers/notifications.helper"; import { UserService } from "../../services/user.service"; import BaseCommand from "../base/base.command"; import { ExecutedCommandResponse } from "../base/command"; @@ -18,7 +17,6 @@ export default class DeleteNotificationsCommand extends BaseCommand> { try { await UserService.getInstance().getNotificationService().deleteMany(this.notifications); - await handleStatusBarUpdate(); this.logAnalytics(new NonSensitiveEventAnalyticsData({})); return this.formatSuccessResponse(this.notifications); diff --git a/codex-vscode/src/commands/notification/markAllNotificationRead.command.ts b/codex-vscode/src/commands/notification/markAllNotificationRead.command.ts index cfa56200..89a1a3a4 100644 --- a/codex-vscode/src/commands/notification/markAllNotificationRead.command.ts +++ b/codex-vscode/src/commands/notification/markAllNotificationRead.command.ts @@ -1,6 +1,5 @@ import { Notification } from "@usecodex/common-library"; import { MESSAGE_TYPES } from "../../globals"; -import { handleSetStatusBarMessage } from "../../helpers/notifications.helper"; import { UserService } from "../../services/user.service"; import BaseCommand from "../base/base.command"; import { ExecutedCommandResponse } from "../base/command"; @@ -24,7 +23,6 @@ export default class MarkAllNotificationsReadCommand extends BaseCommand); - handleSetStatusBarMessage(readNotifications); this.logAnalytics(new NonSensitiveEventAnalyticsData({})); return this.formatSuccessResponse(readNotifications); diff --git a/codex-vscode/src/commands/notification/updateNotification.command.ts b/codex-vscode/src/commands/notification/updateNotification.command.ts index 67be2c87..33e055cd 100644 --- a/codex-vscode/src/commands/notification/updateNotification.command.ts +++ b/codex-vscode/src/commands/notification/updateNotification.command.ts @@ -1,6 +1,5 @@ import { Notification } from "@usecodex/common-library"; import { MESSAGE_TYPES } from "../../globals"; -import { handleStatusBarUpdate } from "../../helpers/notifications.helper"; import { UserService } from "../../services/user.service"; import BaseCommand from "../base/base.command"; import { ExecutedCommandResponse } from "../base/command"; @@ -19,7 +18,6 @@ export default class UpdateNotificationCommand extends BaseCommand await UserService.getInstance() .getNotificationService() .update(this.notification as Notification); - await handleStatusBarUpdate(); return this.formatSuccessResponse(this.notification); } catch (err) { this.logError(err); diff --git a/codex-vscode/src/globals.ts b/codex-vscode/src/globals.ts index 0992b331..62d61a86 100644 --- a/codex-vscode/src/globals.ts +++ b/codex-vscode/src/globals.ts @@ -152,6 +152,8 @@ const enum MESSAGE_TYPES { // URI generateFileUri = "generateFileUri", generateContextUri = "generateContextUri", + + statusBarUpdate = "statusBarUpdate", } const enum NAVIGATION_ERROR_TYPES { diff --git a/codex-vscode/src/helpers/handlers/pusherEvent.handler.ts b/codex-vscode/src/helpers/handlers/pusherEvent.handler.ts index e2e3be7d..4f83c1f2 100644 --- a/codex-vscode/src/helpers/handlers/pusherEvent.handler.ts +++ b/codex-vscode/src/helpers/handlers/pusherEvent.handler.ts @@ -7,7 +7,7 @@ import { UserNotificationType, } from "@usecodex/common-library"; import { MESSAGE_TYPES, PUSHER_EVENT_TYPES } from "../../globals"; -import { displayInformationMessage, handleStatusBarUpdate } from "../notifications.helper"; +import { displayInformationMessage } from "../notifications.helper"; import logger from "../logging.helper"; import { WorkspaceService } from "../../services/workspace.service"; @@ -66,11 +66,11 @@ export async function pusherEventHandler(event: any, data: any) { } } } - data.notification && handleStatusBarUpdate(); // Temporarly disable check for allowNotifications, in Terminal Velocity, we will re-implement this setting. if (data.notification /* && LocalStorageManager.get(LOCAL_STORAGE_KEYS.allowNotifications) */) { displayInformationMessage(data.notification); + SidebarService.getInstance().postMessage(MESSAGE_TYPES.statusBarUpdate); } data.notification && SidebarService.getInstance().postMessage(MESSAGE_TYPES.getNotifications, data.notification); // TODO: make this an array of 1 object diff --git a/codex-vscode/src/helpers/handlers/webviewOutgoingMessage.handler.ts b/codex-vscode/src/helpers/handlers/webviewOutgoingMessage.handler.ts index df2293d3..f9fa8272 100644 --- a/codex-vscode/src/helpers/handlers/webviewOutgoingMessage.handler.ts +++ b/codex-vscode/src/helpers/handlers/webviewOutgoingMessage.handler.ts @@ -58,6 +58,7 @@ import GenerateContextUri from "../../commands/uri/contextUri.command"; import GetSearchSuggestionsCommand from "../../commands/search/getSearchSuggestions.command"; import ExtensionVersion from "../../commands/client/extensionVersion.command"; import ExtensionEnvironment from "../../commands/client/extensionEnvironment.command"; +import StatusBarUpdateCommand from "../../commands/extension/statusBarUpdate.command"; export async function sidebarMessageHandler( message: WebviewOutgoingMessageTypes, @@ -252,11 +253,13 @@ export async function sidebarMessageHandler( case MESSAGE_TYPES.getNotifications: { const getNotifications: GetNotificationsCommand = new GetNotificationsCommand(); clientView.webview.postMessage(await getNotifications.execute()); + sendStatusBarUpdateMessage(clientView); break; } case MESSAGE_TYPES.updateNotification: { const markNotificationReadCommand: UpdateNotificationCommand = new UpdateNotificationCommand(message.value); clientView.webview.postMessage(await markNotificationReadCommand.execute()); + sendStatusBarUpdateMessage(clientView); break; } case MESSAGE_TYPES.markAllNotificationRead: { @@ -264,16 +267,19 @@ export async function sidebarMessageHandler( message.value ); clientView.webview.postMessage(await markAllNotificationReadCommand.execute()); + sendStatusBarUpdateMessage(clientView); break; } case MESSAGE_TYPES.deleteNotification: { const deleteNotificationCommand: DeleteNotificationCommand = new DeleteNotificationCommand(message.value); clientView.webview.postMessage(await deleteNotificationCommand.execute()); + sendStatusBarUpdateMessage(clientView); break; } case MESSAGE_TYPES.deleteNotifications: { const deleteNotificationsCommand: DeleteNotificationsCommand = new DeleteNotificationsCommand(message.value); clientView.webview.postMessage(await deleteNotificationsCommand.execute()); + sendStatusBarUpdateMessage(clientView); break; } case MESSAGE_TYPES.gotoCodexNotificationObject: { @@ -415,6 +421,11 @@ export async function sidebarMessageHandler( clientView.webview.postMessage(await new ExtensionEnvironment().execute()); break; } + case MESSAGE_TYPES.statusBarUpdate: { + const statusBarUpdate = new StatusBarUpdateCommand(message.value); + await statusBarUpdate.execute(); + break; + } case MESSAGE_TYPES.trackEvent: { vscode.commands.executeCommand(COMMAND_TYPES.trackEvent, message.value); break; @@ -425,3 +436,8 @@ export async function sidebarMessageHandler( } } } +function sendStatusBarUpdateMessage(clientView: vscode.WebviewView) { + clientView.webview.postMessage({ + type: MESSAGE_TYPES.statusBarUpdate, + }); +} diff --git a/codex-vscode/src/helpers/notifications.helper.ts b/codex-vscode/src/helpers/notifications.helper.ts index 5f05835d..ee697dbf 100644 --- a/codex-vscode/src/helpers/notifications.helper.ts +++ b/codex-vscode/src/helpers/notifications.helper.ts @@ -12,14 +12,12 @@ import { MESSAGE_TYPES } from "../globals"; const OPEN = "Open"; const OK = "Ok"; -async function handleStatusBarUpdate(): Promise { - const notifications = await UserService.getInstance().getNotifications(); - const notificationMessage = formatStatusBarMessage(notifications); - return updateStatusBar(notificationMessage, vscode.window); +export interface StatusBarData { + notifications: Notification[]; } -function handleSetStatusBarMessage(notifications: Array): vscode.Disposable { - const notificationMessage = formatStatusBarMessage(notifications); +function handleSetStatusBarMessage(statusData: StatusBarData): vscode.Disposable { + const notificationMessage = formatStatusBarMessage(statusData.notifications); return updateStatusBar(notificationMessage, vscode.window); } @@ -54,4 +52,4 @@ function displayInformationMessage(notification: Notification) { }); } -export { handleStatusBarUpdate, handleSetStatusBarMessage, formatStatusBarMessage, displayInformationMessage }; +export { handleSetStatusBarMessage, formatStatusBarMessage, displayInformationMessage }; diff --git a/codex-vscode/src/models/webview/webviewOutgoingMessage.model.ts b/codex-vscode/src/models/webview/webviewOutgoingMessage.model.ts index 6b0a78f7..7aee2368 100644 --- a/codex-vscode/src/models/webview/webviewOutgoingMessage.model.ts +++ b/codex-vscode/src/models/webview/webviewOutgoingMessage.model.ts @@ -85,7 +85,8 @@ export type WebviewOutgoingMessageTypes = | GetExtensionVersion | GetExtensionEnvironment | TrackPageMessage - | TrackEventMessage; + | TrackEventMessage + | StatusBarUpdate; export interface VSCodeMessage { type: T; @@ -201,6 +202,8 @@ type GetExtensionEnvironment = VSCodeMessage; type TrackPageMessage = VSCodeMessage; +type StatusBarUpdate = VSCodeMessage; + interface CodexBaseMessageValue { codexId: number; } @@ -254,3 +257,7 @@ export interface TrackPageMessageValue extends CodexBaseMessageValue { category?: string; properties?: { [key: string]: any }; } + +export interface StatusBarData { + notifications: Notification[]; +} diff --git a/codex-webview/src/globals.ts b/codex-webview/src/globals.ts index 72c80779..bdc0d3bb 100644 --- a/codex-webview/src/globals.ts +++ b/codex-webview/src/globals.ts @@ -152,6 +152,8 @@ const enum MESSAGE_TYPES { // URI generateFileUri = "generateFileUri", generateContextUri = "generateContextUri", + + statusBarUpdate = "statusBarUpdate", } const enum COMMAND_TYPES { diff --git a/codex-webview/src/models/shared/webviewIncomingMessage.model.ts b/codex-webview/src/models/shared/webviewIncomingMessage.model.ts index 58df7a0e..7a17a561 100644 --- a/codex-webview/src/models/shared/webviewIncomingMessage.model.ts +++ b/codex-webview/src/models/shared/webviewIncomingMessage.model.ts @@ -121,6 +121,7 @@ export type WebviewIncomingMessageTypes = | SetExtensionVersion | GetExtensionEnvironment | SetExtensionEnvironment + | StatusBarUpdate // Navigation | NavigateVerificationPage | NavigateOnboardingInviteTeamPage @@ -382,7 +383,7 @@ type GetExtensionVersion = { type: MESSAGE_TYPES.getExtensionVersion; value: und type SetExtensionVersion = ExecutedCommandResponse; type GetExtensionEnvironment = { type: MESSAGE_TYPES.getExtensionEnvironment; value: undefined }; type SetExtensionEnvironment = ExecutedCommandResponse; - +type StatusBarUpdate = ExecutedCommandResponse; // TODO: Break out navigation into own message type. type NavigateNewContextItemPage = { type: MESSAGE_TYPES.navigateNewContextItemPage; @@ -433,3 +434,8 @@ type GoTo = { value: Context[]; }; type NotFound = { type: MESSAGE_TYPES.notFound; value?: { message?: string } }; + +type StatusBarUpdateData = { + type: MESSAGE_TYPES.statusBarUpdate; + value: undefined; +}; diff --git a/codex-webview/src/models/webview/webviewOutgoingMessage.model.ts b/codex-webview/src/models/webview/webviewOutgoingMessage.model.ts index 5dfc12a5..50a2c1d6 100644 --- a/codex-webview/src/models/webview/webviewOutgoingMessage.model.ts +++ b/codex-webview/src/models/webview/webviewOutgoingMessage.model.ts @@ -85,7 +85,8 @@ export type WebviewOutgoingMessageTypes = | GetExtensionVersion | GetExtensionEnvironment | TrackPageMessage - | TrackEventMessage; + | TrackEventMessage + | StatusBarUpdate; export interface VSCodeMessage { type: T; @@ -201,6 +202,8 @@ type GetExtensionEnvironment = VSCodeMessage; type TrackPageMessage = VSCodeMessage; +type StatusBarUpdate = VSCodeMessage; + interface CodexBaseMessageValue { codexId: number; } @@ -254,3 +257,7 @@ export interface TrackPageMessageValue extends CodexBaseMessageValue { category?: string; properties?: { [key: string]: any }; } + +export interface StatusBarData { + notifications: Notification[]; +} diff --git a/codex-webview/src/views/Root.svelte b/codex-webview/src/views/Root.svelte index e0df7845..5def4fef 100644 --- a/codex-webview/src/views/Root.svelte +++ b/codex-webview/src/views/Root.svelte @@ -9,7 +9,7 @@ import VerificationPage from "./pages/VerificationPage.svelte"; import NoRepositoryPage from "./pages/NoRepositoryPage.svelte"; import SearchResultsPage from "./pages/SearchResultsPage.svelte"; - import { activeAdminCodicesStore, clientMessageHandler, collaboratorsStore, defaultCodicesStore, isUserVerifiedStore } from "./helpers/webviewMessageHandler.helper"; + import { activeAdminCodicesStore, clientMessageHandler, collaboratorsStore, defaultCodicesStore, derivedNotificationsStore, isUserVerifiedStore } from "./helpers/webviewMessageHandler.helper"; import { onDestroy, onMount } from "svelte"; import { clearRepositories, fetchRepositoriesAction } from "./stores/actions/repository.actions"; import { fetchUserAccessRequests, resetUserAccessRequests } from "./stores/actions/userAccessRequest.actions"; @@ -155,6 +155,15 @@ resetLabelStore(); resetUser(); break; + case MESSAGE_TYPES.statusBarUpdate: { + messenger.postMessage({ + type: MESSAGE_TYPES.statusBarUpdate, + value: { + notifications: $derivedNotificationsStore, + }, + }); + break; + } } }); }) From 14ead0875f5dc0f66d61a083fe3163acabba61b1 Mon Sep 17 00:00:00 2001 From: Derrick Persson Date: Fri, 22 Jul 2022 08:31:24 -0700 Subject: [PATCH 2/5] let the user know that we couldn't find any remotes (#462) --- .../src/commands/repositories/getRepositories.command.ts | 6 +++--- codex-vscode/src/services/git.service.ts | 8 ++++++++ codex-webview/src/views/components/NoRepository.svelte | 4 +--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/codex-vscode/src/commands/repositories/getRepositories.command.ts b/codex-vscode/src/commands/repositories/getRepositories.command.ts index 63217d92..fe675567 100644 --- a/codex-vscode/src/commands/repositories/getRepositories.command.ts +++ b/codex-vscode/src/commands/repositories/getRepositories.command.ts @@ -1,6 +1,6 @@ import { MESSAGE_TYPES } from "../../globals"; import { VSCodeRepository } from "../../models/shared/vscodeRepository.model"; -import { WorkspaceService } from "../../services/workspace.service"; +import { GitService } from "../../services/git.service"; import BaseCommand from "../base/base.command"; export default class GetRepositoriesCommand extends BaseCommand { @@ -8,8 +8,8 @@ export default class GetRepositoriesCommand extends BaseCommand remote.name === "origin" && remote.fetchUrl); if (originRepo) { return originRepo; diff --git a/codex-webview/src/views/components/NoRepository.svelte b/codex-webview/src/views/components/NoRepository.svelte index d79ba8b5..294f93b8 100644 --- a/codex-webview/src/views/components/NoRepository.svelte +++ b/codex-webview/src/views/components/NoRepository.svelte @@ -1,9 +1,7 @@ - -
-

To get started open a workspace with a git repository.

+

To get started open a workspace with a git repository.

\ No newline at end of file From d43d129c9f5de431b788545c56b6cec6e40742f0 Mon Sep 17 00:00:00 2001 From: Derrick Date: Fri, 22 Jul 2022 08:38:20 -0700 Subject: [PATCH 3/5] Version bump and changelog --- codex-vscode/CHANGELOG.md | 12 ++++++++++++ codex-vscode/package-lock.json | 4 ++-- codex-vscode/package.json | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/codex-vscode/CHANGELOG.md b/codex-vscode/CHANGELOG.md index c87abc6e..28435f9a 100644 --- a/codex-vscode/CHANGELOG.md +++ b/codex-vscode/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to the "codex" extension will be documented in this file. +## [0.5.5] - 2022-07-22 + +### Added +- N/A + +### Changed +- N/A + +### Fixed +- Show the correct unread notification count in the VS Code status bar +- Surface the error for repositories which do not have remotes + ## [0.5.4] - 2022-07-19 ### Added diff --git a/codex-vscode/package-lock.json b/codex-vscode/package-lock.json index e5c9cbd4..0cfeb1ca 100644 --- a/codex-vscode/package-lock.json +++ b/codex-vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "codex-build", - "version": "0.5.4", + "version": "0.5.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codex-build", - "version": "0.5.4", + "version": "0.5.5", "dependencies": { "@sentry/node": "^6.11.0", "@sentry/tracing": "^6.11.0", diff --git a/codex-vscode/package.json b/codex-vscode/package.json index 5983ccdd..c176f6fa 100644 --- a/codex-vscode/package.json +++ b/codex-vscode/package.json @@ -3,7 +3,7 @@ "name": "codex-build", "displayName": "Codex", "description": "Codex makes programming multiplayer.", - "version": "0.5.4", + "version": "0.5.5", "icon": "media/codex.png", "author": "Codex Build Inc.", "repository": {}, From a957c1a4e09903557a043b346c154fa0e9041f03 Mon Sep 17 00:00:00 2001 From: Derrick Persson Date: Fri, 22 Jul 2022 12:19:41 -0700 Subject: [PATCH 4/5] Alerting only when we check for repo's (#465) --- .../repositories/getRepositories.command.ts | 12 ++++++++++++ codex-vscode/src/services/git.service.ts | 17 +++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/codex-vscode/src/commands/repositories/getRepositories.command.ts b/codex-vscode/src/commands/repositories/getRepositories.command.ts index fe675567..cfa40c1f 100644 --- a/codex-vscode/src/commands/repositories/getRepositories.command.ts +++ b/codex-vscode/src/commands/repositories/getRepositories.command.ts @@ -1,3 +1,4 @@ +import * as vscode from "vscode"; import { MESSAGE_TYPES } from "../../globals"; import { VSCodeRepository } from "../../models/shared/vscodeRepository.model"; import { GitService } from "../../services/git.service"; @@ -9,6 +10,17 @@ export default class GetRepositoriesCommand extends BaseCommand !it.hasRemote) + .forEach((repoCheck) => { + vscode.window.showErrorMessage( + `Uh-oh. No remote detected for this repo: ${repoCheck.rootUri}. Please connect a remote to continue.` + ); + }); + const repositories = await gitService.getRepositories(); return this.formatSuccessResponse(repositories); } catch (err) { diff --git a/codex-vscode/src/services/git.service.ts b/codex-vscode/src/services/git.service.ts index 40333e62..6f5ff5c3 100644 --- a/codex-vscode/src/services/git.service.ts +++ b/codex-vscode/src/services/git.service.ts @@ -122,20 +122,21 @@ export class GitService implements Singleton { } } + public checkForRemotes(): { rootUri: string; hasRemote: boolean }[] { + return this.gitAPI.repositories.map((repository) => { + return { + rootUri: repository.rootUri.toString(), + hasRemote: repository?.state?.remotes?.length > 0, + }; + }); + } + /** * Retrieves a remote repository; ideally returns the Origin, but if not, returns a fallback * @param repository * @returns Remote | undefined */ private static getRemote(repository: Repository): Remote | undefined { - // Alert the user that we couldn't find any remotes for the given repo. - if (!repository?.state?.remotes || repository?.state?.remotes.length === 0) { - vscode.window.showErrorMessage( - `Uh-oh. No remote detected for this repo: ${repository.rootUri.toString()}. Please connect a remote to continue.` - ); - return; - } - let originRepo = repository?.state?.remotes?.find((remote) => remote.name === "origin" && remote.fetchUrl); if (originRepo) { return originRepo; From 009d7b35102b7099a0bd92218fee2c71adb637fa Mon Sep 17 00:00:00 2001 From: Derrick Date: Tue, 26 Jul 2022 13:54:39 -0700 Subject: [PATCH 5/5] Fixing bug where notifications would disappear --- codex-webview/src/views/stores/notification.store.ts | 2 +- .../src/views/stores/reducers/notification.reducer.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codex-webview/src/views/stores/notification.store.ts b/codex-webview/src/views/stores/notification.store.ts index 1de7beee..9138240f 100644 --- a/codex-webview/src/views/stores/notification.store.ts +++ b/codex-webview/src/views/stores/notification.store.ts @@ -53,7 +53,7 @@ export const createNotificationStore = (initialState: NotificationState = INITIA ...store, isUpdating: false, errorMessage: "", - notifications: existingNotifications.concat(notification as NotificationEntity), + notifications: [notification as NotificationEntity].concat(existingNotifications), }; }), updateNotification: (notification: NotificationEntity) => diff --git a/codex-webview/src/views/stores/reducers/notification.reducer.ts b/codex-webview/src/views/stores/reducers/notification.reducer.ts index 8c7fcac7..4c37b5e2 100644 --- a/codex-webview/src/views/stores/reducers/notification.reducer.ts +++ b/codex-webview/src/views/stores/reducers/notification.reducer.ts @@ -10,7 +10,11 @@ const notificationReducer = switch (message.type) { case MESSAGE_TYPES.getNotifications: if (message.status === ResponseStatus.success) { - store.setNotifications(Array.isArray(message.value) ? message.value : [message.value]); + if (Array.isArray(message.value)) { + store.setNotifications(message.value); + } else { + store.addNotification(message.value); + } } else { store.setErrorMessage("Could not get notifications"); store.setIsLoading(false);