diff --git a/http/js/iznik/router.js b/http/js/iznik/router.js index 46e8c0f04..d8117343d 100644 --- a/http/js/iznik/router.js +++ b/http/js/iznik/router.js @@ -210,7 +210,7 @@ define([ "mypost/:id/:id": "userMyPostAction", "mypost/:id": "userMyPost", "stories/fornewsletter": "userNewsletterReview", - "stories": "userStories", + "stories(/:id)": "userStories", "story/:id": "userStory", "volunteering": "userVolunteerings", "volunteering/group/(/:id)": "userVolunteerings", @@ -385,12 +385,14 @@ define([ } }, - userStories: function() { + userStories: function(groupid) { if (!MODTOOLS) { var self = this; require(["iznik/views/pages/user/stories"], function () { - var page = new Iznik.Views.User.Pages.Stories(); + var page = new Iznik.Views.User.Pages.Stories({ + groupid: groupid + }); self.loadRoute({page: page}); }); } @@ -1083,6 +1085,7 @@ define([ if (ret.ret === 0) { try { Storage.set('draft', id); + Storage.set('draftrepost', id); if (ret.messagetype == 'Offer') { // Make them reconfirm the location diff --git a/http/js/iznik/views/chat/chat.js b/http/js/iznik/views/chat/chat.js index 14bd8ee37..574f186eb 100644 --- a/http/js/iznik/views/chat/chat.js +++ b/http/js/iznik/views/chat/chat.js @@ -163,10 +163,16 @@ define([ updateCounts: function () { var self = this; var unseen = 0; + var titleunseen = 0; // console.log("update Chat counts"); Iznik.Session.chats.each(function (chat) { + var chattype = chat.get('chattype'); unseen += chat.get('unseen'); + + if (chattype === 'User2User' || chattype === 'User2Mod') { + titleunseen += chat.get('unseen'); + } }); /* CC Iznik.Session.chats.each(function (chat) { var chatView = Iznik.activeChats.viewManager.findByModel(chat); @@ -183,7 +189,7 @@ define([ $(this).empty().hide(); } - Iznik.setTitleCounts(unseen, null); + Iznik.setTitleCounts(titleunseen, null); } }); diff --git a/http/js/iznik/views/pages/modtools/settings.js b/http/js/iznik/views/pages/modtools/settings.js index 34a154d4d..e31dddb57 100644 --- a/http/js/iznik/views/pages/modtools/settings.js +++ b/http/js/iznik/views/pages/modtools/settings.js @@ -363,10 +363,10 @@ define([ }, { name: 'mentored', - label: 'Mentored?', + label: 'Mentor Caretakers?', control: 'radio', options: [{label: 'Yes', value: 1}, {label: 'No', value:0 }], - helpMessage: '(Freegle only) If Yes, this group is being run by Mentors until a local owner can be found.', + helpMessage: '(Freegle only) If Yes, this group is being run by Mentor Caretakers.', disabled: !Iznik.Session.isAdminOrSupport() }, { diff --git a/http/js/iznik/views/pages/pages.js b/http/js/iznik/views/pages/pages.js index 47aba9fb0..dc1947e22 100644 --- a/http/js/iznik/views/pages/pages.js +++ b/http/js/iznik/views/pages/pages.js @@ -455,9 +455,18 @@ define([ e.preventDefault(); e.stopPropagation(); - self.notifications.allSeen().then(function() { - $('.js-notifholder .js-notifcount').css('visibility', 'hidden'); - }); + // Make the count go away. + $('.js-notifholder .js-notifcount').css('visibility', 'hidden'); + + // Fake a click on the notifications to close it. This also means that when + // we reopen it we will refetch it, and then the backgrounds on each notification + // will be correct. + if ($('.dropdown').find('.dropdown-menu').is(":hidden")){ + $('.dropdown-toggle').dropdown('toggle'); + } + + // Update the server in the background. + self.notifications.allSeen(); }); } @@ -848,6 +857,7 @@ define([ render: function() { var self = this; + var p = Iznik.resolvedPromise(self); if (!self.rendered) { diff --git a/http/js/iznik/views/pages/user/explore.js b/http/js/iznik/views/pages/user/explore.js index 7a468058a..0d868b3e0 100644 --- a/http/js/iznik/views/pages/user/explore.js +++ b/http/js/iznik/views/pages/user/explore.js @@ -456,7 +456,9 @@ define([ events: { 'click .js-join': 'join', - 'click .js-leave': 'leave' + 'click .js-leave': 'leave', + 'click .js-locgive': 'locGive', + 'click .js-locfind': 'locFind' }, join: function() { @@ -493,6 +495,24 @@ define([ }) ; }, + locGive: function() { + // This group has a default location. Set it as our location and skip the "where am I" page. + var self = this; + Storage.set('myhomegroup', self.model.get('id')); + Storage.set('myhomegrouptime', (new Date()).getTime()); + Storage.set('mylocation', JSON.stringify(self.model.get('defaultlocation'))) + Router.navigate('/give/whatisit', true); + }, + + locFind: function() { + // This group has a default location. Set it as our location and skip straight to post a wanted + var self = this; + Storage.set('myhomegroup', self.model.get('id')); + Storage.set('myhomegrouptime', (new Date()).getTime()); + Storage.set('mylocation', JSON.stringify(self.model.get('defaultlocation'))) + Router.navigate('/find/whatisit', true); + }, + filter: function(model) { var thetype = model.get('type'); diff --git a/http/js/iznik/views/pages/user/home.js b/http/js/iznik/views/pages/user/home.js index d6aead7a9..c9cd4501c 100644 --- a/http/js/iznik/views/pages/user/home.js +++ b/http/js/iznik/views/pages/user/home.js @@ -477,7 +477,7 @@ define([ // We don't have the full model, because we only fetched a summary. Get the full // version and re-render. self.expanded = true; - self.model.fetch().then(self.render); + self.model.fetch().then(_.bind(self.render, self)); // Abort the panel toggle - will happen once next render fires. return (false); @@ -545,7 +545,7 @@ define([ // We don't have the full model, because we only fetched a summary. Get the full // version and re-render. self.expanded = true; - self.model.fetch().then(self.render); + self.model.fetch().then(_.bind(self.render, self)); // Abort the panel toggle - will happen once next render fires. return(false); diff --git a/http/js/iznik/views/pages/user/pages.js b/http/js/iznik/views/pages/user/pages.js index 963f3c906..eceb80863 100644 --- a/http/js/iznik/views/pages/user/pages.js +++ b/http/js/iznik/views/pages/user/pages.js @@ -185,7 +185,6 @@ define([ } try { - console.log("Save home group", val); Storage.set('myhomegroup', val); Storage.set('myhomegrouptime', (new Date()).getTime()); } catch (e) {} @@ -263,7 +262,6 @@ define([ self.$('.js-next').hide(); self.$('.js-external').hide(); - console.log("changeGroup", first); if (first) { self.$('.js-closestgroupname').html(first.namedisplay); @@ -324,74 +322,86 @@ define([ if (groups.length > 0) { // We have a group select dropdown on the page. if (self.groupsnear) { - // We have some groups near their chosen location. - var homegroup = null; - var homegrouptime = null; - var homegroupfound = false; - var firstonhere = null; - - try { - homegroup = Storage.get('myhomegroup'); - homegrouptime = Storage.get('myhomegrouptime'); - } catch (e) {}; - - // If the first group has been founded since the home group was set up, then we want to - // use that rather than a previous preference. Otherwise new groups don't get existing - // members from their area. - if (self.groupsnear.length > 0) { - var g = self.groupsnear[0]; - if (g) { - var founded = (new Date(g.founded)).getTime(); - if (!homegrouptime || homegrouptime < founded) { - homegroup = g.id; - try { - Storage.set('myhomegroup', homegroup); - Storage.set('myhomegrouptime', (new Date()).getTime()); - } catch (e) {}; + self.listenToOnce(Iznik.Session, 'isLoggedIn', function (loggedIn) { + // We have some groups near their chosen location. + var mygroups = Iznik.Session.get('groups'); + mygroups.each(function(group) { + if (group.get('type') == 'Freegle' && + group.get('privategroup')) { + // We are a member of a private group. That should appear at the top. + groups.append('