Skip to content
This repository has been archived by the owner. It is now read-only.

[IP-618] [Search] Onboarding for existing users #397

Merged
merged 7 commits into from Jul 22, 2019
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

fixed search onboarding problem

  • Loading branch information
Pavel
Pavel committed Jul 22, 2019
commit 913884b22c936e764f545c9c02ffe1024a5f603b
@@ -30,8 +30,8 @@ open class Engine {
#else
let jsCodeLocation = Bundle.main.url(forResource: "jsengine.bundle", withExtension: "js")
#endif
rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "ExtensionApp", initialProperties: ["showSearchOnboarding": UserPreferences.instance.showSearchOnboarding], launchOptions: nil )

rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "ExtensionApp", initialProperties: nil, launchOptions: nil )
bridge = rootView.bridge
//ConnectManager.sharedInstance.refresh()
}
@@ -93,6 +93,11 @@ class JSBridge : RCTEventEmitter {
}
}
}

@objc(getConfig:reject:)
func getConfig(resolve: @escaping RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
resolve(["onboarding": UserPreferences.instance.showSearchOnboarding])
}

/// Call an action over the JSBridge and execute a callback with the result. Invokation of the callback is
/// not guaranteed, for example if the function is never registered. Unlike the synchronous version, this
@@ -13,5 +13,6 @@ @interface RCT_EXTERN_MODULE(JSBridge, NSObject)
RCT_EXTERN_METHOD(replyToAction:(nonnull NSInteger *)actionId result:(NSDictionary *)result)
RCT_EXTERN_METHOD(registerAction:)
RCT_EXTERN_METHOD(pushEvent:(nonnull NSString *)eventId data:(NSArray *)data)
RCT_EXTERN_METHOD(getConfig:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)

@end
@@ -59,19 +59,29 @@ class MobileCards extends React.Component {
constructor(props) {
super(props);
this.state = {
onboarding: props.showSearchOnboarding,
onboarding: false,
results: {
results: [],
meta: {}
},
isReady: false,
hasQuery: false,
theme: 'lumen-light'
}

this.cliqz = new Cliqz();
this.isDeveloper = prefs.get('developer', false);
this.appStart = appStart || Promise.resolve();
this.init();
}

async init() {
await this.appStart;
const config = await nativeBridge.getConfig();
this.setState({
onboarding: config.onboarding,
isReady: true,
});
events.sub('search:results', this.updateResults);
events.sub('mobile-browser:notify-preferences', this.updatePreferences);
events.sub('mobile-browser:set-search-engine', this.setSearchEngine);
@@ -138,6 +148,9 @@ class MobileCards extends React.Component {
}

render() {
if (!this.state.isReady) {
return null;
}
const { results, suggestions, meta, query } = this.state.results;
const appearance = this.state.theme;
const layout = 'vertical';
ProTip! Use n and p to navigate between commits in a pull request.