-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-14219] Add service for new device verification notice #11988
Changes from 3 commits
bf305f7
b5d93e0
535f7d9
b85e1e9
b9bbad7
106cd59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Observable } from "rxjs"; | ||
|
||
import { | ||
ActiveUserState, | ||
StateProvider, | ||
UserKeyDefinition, | ||
NEW_DEVICE_VERIFICATION_NOTICE, | ||
} from "@bitwarden/common/platform/state"; | ||
|
||
export type NewDeviceVerificationNotice = { | ||
last_dismissal: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ What type of values will |
||
permanent_dismissal: boolean; | ||
}; | ||
|
||
const NEW_DEVICE_VERIFICATION_NOTICE_KEY = new UserKeyDefinition<NewDeviceVerificationNotice>( | ||
NEW_DEVICE_VERIFICATION_NOTICE, | ||
"noticeState", | ||
{ | ||
deserializer: (jsonData) => jsonData, | ||
clearOn: [], | ||
}, | ||
); | ||
|
||
@Injectable() | ||
export class NewDeviceVerificationNoticeService { | ||
private noticeState: ActiveUserState<NewDeviceVerificationNotice>; | ||
noticeState$: Observable<NewDeviceVerificationNotice>; | ||
|
||
constructor(private stateProvider: StateProvider) { | ||
this.noticeState = this.stateProvider.getActive(NEW_DEVICE_VERIFICATION_NOTICE_KEY); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
noticeState$(userId: userId) {
return this.stateProvider.getUser(userId, NEW_DEVICE_VERIFICATION_NOTICE_KEY).state$;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can reference this |
||
this.noticeState$ = this.noticeState.state$; | ||
} | ||
|
||
async updateNewDeviceVerificationNoticeState( | ||
newState: NewDeviceVerificationNotice, | ||
): Promise<void> { | ||
await this.noticeState.update(() => { | ||
return { ...newState }; | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐จ We should add some documentation on what these values represent / how they're expected to be used.