Skip to content

Commit

Permalink
* Improve handling of switching between searching for offers/wanteds
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jun 21, 2018
1 parent 8ee6613 commit 9b735d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions http/js/iznik/views/pages/user/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,30 @@ define([

restoreSearchType: function() {
var self = this;
console.log("Restore search type");
try {
var t = Storage.get('searchtype');
console.log("Got", t);
if (t) {
this.$('.js-searchchoose').show();
self.$(".js-searchoffers").boostrapSwitch('state', t == 'Offer' );
}
} catch (e) {}
},

changeSearchType: function() {
// If we change the type of the search when there is something in the search box, do the search again (for
// the new type). This means they don't need to figure out to hit the Search button again, which wouldn't
// work anyway because we are already on the correct URL.
this.saveSearchType();
var term = this.$('.js-search').val();
if (term.length > 0) {
this.render();
var self = this;

self.saveSearchType();

if (self.options.search) {
// If we change the type of the search when there is something in the search box, do the search again (for
// the new type). This means they don't need to figure out to hit the Search button again, which wouldn't
// work anyway because we are already on the correct URL.
self.fetchData.messagetype = Storage.get('searchtype');
self.collection.reset();
self.context = null;
self.fetch(self.fetchData);
}
},

Expand Down Expand Up @@ -141,6 +149,7 @@ define([
});

p.then(function(self) {
self.restoreSearchType();
self.collection = null;

if (window.hasOwnProperty('webkitSpeechRecognition')) {
Expand Down Expand Up @@ -171,7 +180,6 @@ define([

if (self.options.search) {
// We've searched for something - we're showing the results.
self.restoreSearchType();
self.$('h1').hide();
self.$('.js-search').val(self.options.search);

Expand Down
2 changes: 1 addition & 1 deletion http/js/iznik/views/user/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ define([
render: function() {
var self = this;
var p;
console.log("Render message", self.model);
// console.log("Render message", self.model);

if (self.rendered) {
p = Iznik.resolvedPromise(self);
Expand Down

0 comments on commit 9b735d7

Please sign in to comment.