Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rbalicki2 committed Oct 10, 2022
1 parent 31bedd9 commit f855cdf
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
29 changes: 29 additions & 0 deletions Libraries/Core/cachedSettingsStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

const settingsModule = require('../Settings/Settings');
const REACT_DEVTOOLS_SETTINGS_KEY_PREFIX = 'ReactDevTools::Settings::';

export type CachedSettingsStore = {
setValue: (key: string, value: string) => void,
getValue: (key: string) => ?string,
};

function getFullKey(suffix: string): string {
return `${REACT_DEVTOOLS_SETTINGS_KEY_PREFIX}${suffix}`;
}

const cachedSettingsStore: CachedSettingsStore = {
setValue: (key, value) => {
try {
settingsModule.set({
[getFullKey(key)]: value,
});
} catch {}
},
getValue: (key) => {
try {
return settingsModule.get(getFullKey(key));
} catch {}
},
};

module.exports = cachedSettingsStore;
2 changes: 2 additions & 0 deletions Libraries/Core/setUpReactDevTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (__DEV__) {
});

const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes');
const cachedSettingsStore = require('./cachedSettingsStore');

reactDevTools.connectToDevTools({
isAppActive,
Expand All @@ -70,6 +71,7 @@ if (__DEV__) {
ReactNativeStyleAttributes,
),
websocket: ws,
cachedSettingsStore,
});
}
};
Expand Down
8 changes: 6 additions & 2 deletions Libraries/Settings/Settings.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@

'use strict';

import NativeSettingsManager from './NativeSettingsManager';

const Settings = {
get(key: string): mixed {
console.warn('Settings is not yet supported on Android');
console.log({NativeSettingsManager})
return null;
},

set(settings: Object) {
console.log({NativeSettingsManager})
console.warn('Settings is not yet supported on Android');
},

watchKeys(keys: string | Array<string>, callback: Function): number {
console.warn('Settings is not yet supported on Android');
console.warn('watchKeys is not yet supported on Android');
return -1;
},

clearWatch(watchId: number) {
console.warn('Settings is not yet supported on Android');
console.warn('clearWatch is not yet supported on Android');
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library")

rn_android_library(
name = "settings",
srcs = glob(["**/*.java"]),
autoglob = False,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
language = "JAVA",
visibility = [
"PUBLIC",
],
deps = [
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
react_native_target("java/com/facebook/react/modules/core:core"),
],
exported_deps = [react_native_root_target(":FBReactNativeSpec")],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.modules.settings;

import com.facebook.fbreact.specs.NativeSettingsManagerSpec;
import com.facebook.react.module.annotations.ReactModule;

@ReactModule(name = SettingsManagerModule.NAME)
public class SettingsManagerModule extends NativeSettingsManagerSpec {
public static final String NAME = "SettingsManager";
}

0 comments on commit f855cdf

Please sign in to comment.