Skip to content

Commit 562e0f6

Browse files
committed
#RIVS-287 - Decompressor not applied to opened connection
1 parent 7654911 commit 562e0f6

File tree

15 files changed

+81
-40
lines changed

15 files changed

+81
-40
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"**/yarn.lock": true,
4242
"*.{css,sass,scss}.d.ts": true,
4343
"pnpm-lock.yaml": true,
44-
"**/pnpm-lock.yaml": true
44+
"**/pnpm-lock.yaml": true,
45+
"**/test-extensions": true
4546
},
4647
"cSpell.words": ["githubocto", "tailwindcss", "webviews", "zustand"],
4748
"testing.automaticallyOpenPeekView": "never",

src/Webview.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type WebviewOptions = {
1111
styleUri?: vscode.Uri
1212
nonce?: string
1313
message?: {
14+
action?: string
1415
data: object
1516
}
1617
column?: vscode.ViewColumn
@@ -113,6 +114,7 @@ abstract class Webview {
113114

114115
public abstract update(opts?: WebviewOptions): void
115116
public abstract setTitle(title: string): void
117+
public abstract postMessage(message: any): void
116118
}
117119

118120
export class WebviewPanel extends Webview implements vscode.Disposable {
@@ -211,6 +213,10 @@ export class WebviewPanel extends Webview implements vscode.Disposable {
211213
this.panel.title = title
212214
}
213215

216+
public postMessage(message: any) {
217+
this.panel.webview.postMessage(message)
218+
}
219+
214220
public dispose() {
215221
// Disposes of this instance
216222
// Next time getInstance() is called, it will construct a new instance

src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ export async function activate(context: vscode.ExtensionContext) {
165165
vscode.commands.registerCommand('RedisForVSCode.editDatabaseClose', (args) => {
166166
WebviewPanel.getInstance({ viewId: ViewId.EditDatabase }).dispose()
167167
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree', data: args })
168+
169+
const keyDetailsWebview = WebviewPanel.instances[ViewId.Key]
170+
if (keyDetailsWebview) {
171+
keyDetailsWebview.postMessage({ action: 'RefreshKey', data: args })
172+
}
168173
}),
169174

170175
vscode.commands.registerCommand('RedisForVSCode.closeAddKeyAndRefresh', (args) => {

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const handleMessage = async (message: any = {}) => {
5656
vscode.commands.executeCommand('RedisForVSCode.addDatabaseClose')
5757
break
5858
case 'CloseEditDatabase':
59-
vscode.commands.executeCommand('RedisForVSCode.editDatabaseClose', message)
59+
vscode.commands.executeCommand('RedisForVSCode.editDatabaseClose', message.data)
6060
break
6161
case 'UpdateSettings':
6262
await setUIStorageField('appInfo', {

src/webviews/src/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { selectKeyAction } from './selectKeyAction'
22
export { addKeyAction } from './addKeyAction'
33
export { refreshTreeAction } from './refreshTreeAction'
4+
export { refreshKeyAction } from './refreshKeyAction'
45
export { processCliAction } from './processCliAction'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { VscodeMessageAction } from 'uiSrc/constants'
2+
import { PostMessage } from 'uiSrc/interfaces'
3+
import { useDatabasesStore } from 'uiSrc/store'
4+
5+
export const refreshKeyAction = (message: PostMessage) => {
6+
if (message.action !== VscodeMessageAction.RefreshKey) {
7+
return
8+
}
9+
10+
if (message.data?.database?.id) {
11+
useDatabasesStore.getState().setConnectedDatabase(message.data.database)
12+
}
13+
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { VscodeMessageAction } from 'uiSrc/constants'
22
import { PostMessage } from 'uiSrc/interfaces'
3-
import { fetchDatabases, useSelectedKeyStore } from 'uiSrc/store'
3+
import { fetchDatabases, useDatabasesStore, useSelectedKeyStore } from 'uiSrc/store'
44

55
export const refreshTreeAction = (message: PostMessage) => {
66
if (message.action !== VscodeMessageAction.RefreshTree) {
77
return
88
}
99
if (message.data?.keyInfo?.key) {
1010
useSelectedKeyStore.getState().setSelectedKeyAction(message.data)
11-
} else {
12-
fetchDatabases()
1311
}
12+
13+
fetchDatabases(() => {
14+
if (message.data.database?.id) {
15+
useDatabasesStore.getState().setDatabaseToList(message.data?.database!)
16+
}
17+
})
1418
}

src/webviews/src/constants/vscode/vscode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum VscodeMessageAction {
1111
SelectKey = 'SelectKey',
1212
OpenCli = 'OpenCli',
1313
RefreshTree = 'RefreshTree',
14+
RefreshKey = 'RefreshKey',
1415
CloseKey = 'CloseKey',
1516
CloseKeyAndRefresh = 'CloseKeyAndRefresh',
1617
EditKeyName = 'EditKeyName',

src/webviews/src/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
processCliAction,
1919
refreshTreeAction,
2020
selectKeyAction,
21+
refreshKeyAction,
2122
} from './actions'
2223
import { MonacoLanguages } from './components'
2324

@@ -46,6 +47,9 @@ document.addEventListener('DOMContentLoaded', () => {
4647
case VscodeMessageAction.CloseEula:
4748
useAppInfoStore.getState().setIsShowConcepts(false)
4849
break
50+
case VscodeMessageAction.RefreshKey:
51+
refreshKeyAction(message)
52+
break
4953
case VscodeMessageAction.RefreshTree:
5054
refreshTreeAction(message)
5155
break

src/webviews/src/interfaces/vscode/api.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ export interface SelectKeyAction {
2626
}
2727
}
2828

29-
export interface RefreshTreeAction {
30-
action: VscodeMessageAction.RefreshTree
31-
data: { key?: RedisString, type: SelectedKeyActionType, databaseId: string }
32-
}
33-
3429
export interface DatabaseAction {
35-
action: VscodeMessageAction.EditDatabase | VscodeMessageAction.AddKey | VscodeMessageAction.AddCli | VscodeMessageAction.OpenCli
30+
action: VscodeMessageAction.EditDatabase
31+
| VscodeMessageAction.AddKey
32+
| VscodeMessageAction.AddCli
33+
| VscodeMessageAction.OpenCli
34+
| VscodeMessageAction.CloseEditDatabase
3635
data: {
3736
database: Database
3837
}
@@ -50,27 +49,33 @@ export interface SelectedKeyAction {
5049
VscodeMessageAction.RefreshTree |
5150
VscodeMessageAction.EditKeyName
5251
data: {
53-
database: Database,
54-
type: SelectedKeyActionType,
52+
database: Database
53+
type: SelectedKeyActionType
5554
keyInfo: {
56-
key?: RedisString,
57-
keyType?: KeyTypes,
58-
newKey?: RedisString,
59-
newKeyString?: string,
55+
key?: RedisString
56+
keyType?: KeyTypes
57+
newKey?: RedisString
58+
newKeyString?: string
6059
keyString?: string
6160
displayedKeyType?: string
6261
}
6362
}
6463
}
6564

65+
export interface RefreshAction {
66+
action: VscodeMessageAction.RefreshKey
67+
data: {
68+
database?: Database
69+
}
70+
}
71+
6672
export interface SelectedKeyCloseAction {
6773
action: VscodeMessageAction.CloseKey
6874
}
6975

7076
export interface NoDataAction {
7177
action: VscodeMessageAction.CloseAddDatabase
7278
| VscodeMessageAction.OpenAddDatabase
73-
| VscodeMessageAction.CloseEditDatabase
7479
}
7580

7681
export interface CloseAddKeyAction {
@@ -89,12 +94,12 @@ export interface UpdateSettingsDelimiterAction {
8994
}
9095

9196
export interface SaveAppInfoAction {
92-
action: VscodeMessageAction.SaveAppInfo,
97+
action: VscodeMessageAction.SaveAppInfo
9398
data: Partial<AppInfoStore>
9499
}
95100

96101
export interface ShowEulaAction {
97-
action: VscodeMessageAction.ShowEula,
102+
action: VscodeMessageAction.ShowEula
98103
}
99104

100105
export interface CloseEulaAction {
@@ -114,4 +119,5 @@ export type PostMessage =
114119
SaveAppInfoAction |
115120
ShowEulaAction |
116121
CloseEulaAction |
117-
ResetSelectedKeyAction
122+
ResetSelectedKeyAction |
123+
RefreshAction

0 commit comments

Comments
 (0)