Unverified Commit 791ef4d4 authored by Gleidson Daniel Silva's avatar Gleidson Daniel Silva Committed by GitHub
Browse files

Chore: Migrate lib user preferences to Typescript (#3578)

parent 13af9d80
......@@ -7,11 +7,12 @@ const MMKV = new MMKVStorage.Loader()
.initialize();
class UserPreferences {
private mmkv: MMKVStorage.API;
constructor() {
this.mmkv = MMKV;
}
async getStringAsync(key) {
async getStringAsync(key: string) {
try {
const value = await this.mmkv.getStringAsync(key);
return value;
......@@ -20,11 +21,11 @@ class UserPreferences {
}
}
setStringAsync(key, value) {
setStringAsync(key: string, value: string) {
return this.mmkv.setStringAsync(key, value);
}
async getBoolAsync(key) {
async getBoolAsync(key: string) {
try {
const value = await this.mmkv.getBoolAsync(key);
return value;
......@@ -33,11 +34,11 @@ class UserPreferences {
}
}
setBoolAsync(key, value) {
setBoolAsync(key: string, value: boolean) {
return this.mmkv.setBoolAsync(key, value);
}
async getMapAsync(key) {
async getMapAsync(key: string) {
try {
const value = await this.mmkv.getMapAsync(key);
return value;
......@@ -46,11 +47,11 @@ class UserPreferences {
}
}
setMapAsync(key, value) {
setMapAsync(key: string, value: object) {
return this.mmkv.setMapAsync(key, value);
}
removeItem(key) {
removeItem(key: string) {
return this.mmkv.removeItem(key);
}
}
......
......@@ -107,7 +107,7 @@ class DefaultBrowserView extends React.Component<IDefaultBrowserViewProps, IDefa
changeDefaultBrowser = async (newBrowser: TValue) => {
logEvent(events.DB_CHANGE_DEFAULT_BROWSER, { browser: newBrowser });
try {
const browser = newBrowser !== 'systemDefault:' ? newBrowser : null;
const browser = newBrowser || 'systemDefault:';
await UserPreferences.setStringAsync(DEFAULT_BROWSER_KEY, browser);
this.setState({ browser });
} catch {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment