Skip to content

Commit 7410b54

Browse files
committed
fix search langs restore not working
1 parent d2d1909 commit 7410b54

8 files changed

Lines changed: 24 additions & 23 deletions

File tree

‎dist/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><title>CODELF</title><meta name="description" content="Best GitHub stars, repositories tagger and organizer. Search over projects from Github, Bitbucket, Google Code, Codeplex, Sourceforge, Fedora Project, GitLab to find real-world usage variable names."><meta name="keywords" content="Codelf,变量命名,函数命名,方法命名,变量命名神器,GitHub 分组,Organize GitHub stars,naming things,naming convention,programming naming"><meta http-equiv="x-ua-compatible" content="ie=edge"><link rel="shortcut icon" href="images/codelf_logo.f4ae25bd.png"><link rel="apple-touch-icon" sizes="144x144" href="images/codelf_logo.f4ae25bd.png"><link rel="apple-touch-icon-precomposed" href="images/codelf_logo.f4ae25bd.png"><link title="CODELF" type="application/opensearchdescription+xml" rel="search" href="./opensearch.xml"><link type="text/css" rel="stylesheet" href="./css/lib.365f8ae0.css"><link type="text/css" rel="stylesheet" href="./css/app.785e1245.css"><script src="js/lib.2ef380a5.js"></script></head><body ontouchstart><div class="app"></div><script src="./js/app.c6eb6818.js"></script><script>if (/https/.test(location.protocol) && 'serviceWorker' in navigator) {
1+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><title>CODELF</title><meta name="description" content="Best GitHub stars, repositories tagger and organizer. Search over projects from Github, Bitbucket, Google Code, Codeplex, Sourceforge, Fedora Project, GitLab to find real-world usage variable names."><meta name="keywords" content="Codelf,变量命名,函数命名,方法命名,变量命名神器,GitHub 分组,Organize GitHub stars,naming things,naming convention,programming naming"><meta http-equiv="x-ua-compatible" content="ie=edge"><link rel="shortcut icon" href="images/codelf_logo.f4ae25bd.png"><link rel="apple-touch-icon" sizes="144x144" href="images/codelf_logo.f4ae25bd.png"><link rel="apple-touch-icon-precomposed" href="images/codelf_logo.f4ae25bd.png"><link title="CODELF" type="application/opensearchdescription+xml" rel="search" href="./opensearch.xml"><link type="text/css" rel="stylesheet" href="./css/lib.365f8ae0.css"><link type="text/css" rel="stylesheet" href="./css/app.785e1245.css"><script src="js/lib.2ef380a5.js"></script></head><body ontouchstart><div class="app"></div><script src="./js/app.a61232b5.js"></script><script>if (/https/.test(location.protocol) && 'serviceWorker' in navigator) {
22
if (!Cache.prototype.add) {
33
Cache.prototype.add = function add(request) {
44
return this.addAll([request]);
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/js/app.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/js/app.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/sw.js‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// cache, then increment the CACHE_VERSION value. It will kick off the service worker update
2525
// flow and the old cache(s) will be purged as part of the activate event handler when the
2626
// updated service worker is activated.
27-
var CACHE_VERSION = '2019-01-02T16:36:05.566Z';
27+
var CACHE_VERSION = '2019-01-02T16:59:36.232Z';
2828
var CURRENT_CACHES = {
2929
prefetch: 'prefetch-cache-v' + CACHE_VERSION
3030
};
@@ -37,6 +37,18 @@ self.addEventListener('install', function(event) {
3737
"css/app.css",
3838
"css/lib.365f8ae0.css",
3939
"css/lib.css",
40+
"fonts/Dressedless_Three.svg",
41+
"fonts/Dressedless_Three.ttf",
42+
"fonts/FontAwesome.otf",
43+
"fonts/LatoLatin-Bold.woff2",
44+
"fonts/LatoLatin-BoldItalic.woff2",
45+
"fonts/LatoLatin-Italic.woff2",
46+
"fonts/LatoLatin-Regular.woff2",
47+
"fonts/fontawesome-webfont.eot",
48+
"fonts/fontawesome-webfont.svg",
49+
"fonts/fontawesome-webfont.ttf",
50+
"fonts/fontawesome-webfont.woff",
51+
"fonts/fontawesome-webfont.woff2",
4052
"images/404_dribbble.ae94d03c.gif",
4153
"images/404_dribbble.gif",
4254
"images/codelf_logo.f4ae25bd.png",
@@ -49,22 +61,10 @@ self.addEventListener('install', function(event) {
4961
"images/wechatpay.jpg",
5062
"images/zhifubao.70c19370.png",
5163
"images/zhifubao.png",
52-
"js/app.c6eb6818.js",
64+
"js/app.a61232b5.js",
5365
"js/app.js",
5466
"js/lib.2ef380a5.js",
5567
"js/lib.js",
56-
"fonts/Dressedless_Three.svg",
57-
"fonts/Dressedless_Three.ttf",
58-
"fonts/FontAwesome.otf",
59-
"fonts/LatoLatin-Bold.woff2",
60-
"fonts/LatoLatin-BoldItalic.woff2",
61-
"fonts/LatoLatin-Italic.woff2",
62-
"fonts/LatoLatin-Regular.woff2",
63-
"fonts/fontawesome-webfont.eot",
64-
"fonts/fontawesome-webfont.svg",
65-
"fonts/fontawesome-webfont.ttf",
66-
"fonts/fontawesome-webfont.woff",
67-
"fonts/fontawesome-webfont.woff2",
6868
"css/themes/default/assets/fonts/brand-icons.eot",
6969
"css/themes/default/assets/fonts/brand-icons.svg",
7070
"css/themes/default/assets/fonts/brand-icons.ttf",

‎src/components/SearchBar.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class SearchBar extends React.Component {
3535
constructor(props) {
3636
super(props);
3737
this.state = {
38-
lang: [],
38+
lang: props && props.searchLang ? props.searchLang : [],
3939
prevProps: props,
4040
inputSize: 'huge',
4141
inputChanged: false

‎src/containers/MainContainer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class MainContainer extends React.Component {
6868
page = 0;
6969
}
7070
this.setState({searchValue: val, requestingVariable: true});
71-
SearchCodeModel.requestVariable(val, page, lang || this.state.searchLang);
71+
SearchCodeModel.requestVariable(val, page, lang);
7272
AppModel.analytics('q=' + val);
7373
DDMSModel.postKeyWords(val);
7474
}

‎src/models/SearchCodeModel.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SearchCodeModel extends BaseModel {
1616
this._data = {
1717
isZH: false,
1818
searchValue: null,
19-
searchLang: SessionStorage.getItem(SEARCH_LANG_KEY) || [],
19+
searchLang: SessionStorage.getItem(SEARCH_LANG_KEY),
2020
page: 0,
2121
variableList: [],
2222
suggestion: [],
@@ -35,7 +35,8 @@ class SearchCodeModel extends BaseModel {
3535

3636
//search code by query
3737
async requestVariable(val, page, lang) {
38-
SessionStorage.setItem(SEARCH_LANG_KEY, lang || []); // persist lang
38+
lang = lang || this.searchLang;
39+
SessionStorage.setItem(SEARCH_LANG_KEY, lang); // persist lang
3940
if (val !== undefined && val !== null) {
4041
val = val.trim().replace(/\s+/ig, ' '); // filter spaces
4142
}
@@ -207,7 +208,7 @@ class SearchCodeModel extends BaseModel {
207208
}
208209

209210
get searchLang() {
210-
return this._data.searchLang;
211+
return this._data.searchLang || SessionStorage.getItem(SEARCH_LANG_KEY) || [];
211212
}
212213

213214
get page() {

0 commit comments

Comments
 (0)