Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle notification of another member being removed #2525

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ItemManagerInterface } from '../Item/ItemManagerInterface'
import { SessionsClientInterface } from '../Session/SessionsClientInterface'
import { ContactPublicKeySetInterface, TrustedContactInterface } from '@standardnotes/models'
import { SyncLocalVaultsWithRemoteSharedVaults } from './UseCase/SyncLocalVaultsWithRemoteSharedVaults'
import { VaultUserServiceInterface } from '../VaultUser/VaultUserServiceInterface'

describe('SharedVaultService', () => {
let service: SharedVaultService
Expand All @@ -27,6 +28,8 @@ describe('SharedVaultService', () => {
const items = {} as jest.Mocked<ItemManagerInterface>
items.addObserver = jest.fn()

const vaultUsers = {} as jest.Mocked<VaultUserServiceInterface>

const session = {} as jest.Mocked<SessionsClientInterface>
const getVault = {} as jest.Mocked<GetVault>
const getOwnedVaults = {} as jest.Mocked<GetOwnedSharedVaults>
Expand All @@ -48,6 +51,7 @@ describe('SharedVaultService', () => {
service = new SharedVaultService(
items,
session,
vaultUsers,
syncLocalVaultsWithRemoteSharedVaults,
getVault,
getOwnedVaults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { HandleKeyPairChange } from '../Contacts/UseCase/HandleKeyPairChange'
import { FindContact } from '../Contacts/UseCase/FindContact'
import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults'
import { SyncLocalVaultsWithRemoteSharedVaults } from './UseCase/SyncLocalVaultsWithRemoteSharedVaults'
import { VaultUserServiceInterface } from '../VaultUser/VaultUserServiceInterface'

export class SharedVaultService
extends AbstractService<SharedVaultServiceEvent, SharedVaultServiceEventPayload>
Expand All @@ -41,6 +42,7 @@ export class SharedVaultService
constructor(
private items: ItemManagerInterface,
private session: SessionsClientInterface,
private vaultUsers: VaultUserServiceInterface,
private _syncLocalVaultsWithRemoteSharedVaults: SyncLocalVaultsWithRemoteSharedVaults,
private _getVault: GetVault,
private _getOwnedSharedVaults: GetOwnedSharedVaults,
Expand Down Expand Up @@ -110,6 +112,10 @@ export class SharedVaultService
}
break
}
case NotificationType.TYPES.UserRemovedFromSharedVault: {
this.vaultUsers.invalidateVaultUsersCache(event.eventPayload.props.sharedVaultUuid.value).catch(console.error)
break
}
case NotificationType.TYPES.SharedVaultItemRemoved: {
const item = this.items.findItem((event.eventPayload.props.itemUuid as Uuid).value)
if (item) {
Expand Down
1 change: 1 addition & 0 deletions packages/snjs/lib/Application/Dependencies/Dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ export class Dependencies {
return new SharedVaultService(
this.get<ItemManager>(TYPES.ItemManager),
this.get<SessionManager>(TYPES.SessionManager),
this.get<VaultUserService>(TYPES.VaultUserService),
this.get<SyncLocalVaultsWithRemoteSharedVaults>(TYPES.SyncLocalVaultsWithRemoteSharedVaults),
this.get<GetVault>(TYPES.GetVault),
this.get<GetOwnedSharedVaults>(TYPES.GetOwnedSharedVaults),
Expand Down