Update webapp for /status changes
});
req.go();
},
- getFeedInfo: function() {
+ getStatus: function() {
if (!blerg.API.loggedIn)
throw new Error('Cannot request feed status when not logged in');
var req = new enyo.Ajax({
- url: baseURL + '/feedinfo',
+ url: baseURL + '/status',
method: 'POST',
postBody: {
username: blerg.API.username
}
});
req.response(this, function(inSender, inResponse) {
- this.bubble('onFeedInfo', inResponse);
+ this.bubble('onStatus', inResponse);
+ });
+ req.go();
+ },
+ clearStatus: function(type) {
+ if (!blerg.API.loggedIn)
+ throw new Error('Cannot request feed status when not logged in');
+
+ if (!(type == 'feed' || type == 'mentioned'))
+ throw new Error('Invalid status clear type: ' + type);
+
+ var req = new enyo.Ajax({
+ url: baseURL + '/status',
+ method: 'POST',
+ postBody: {
+ username: blerg.API.username,
+ clear: type
+ }
+ });
+ req.response(this, function(inSender, inResponse) {
+ inResponse.type = type;
+ this.bubble('onClearStatus', inResponse);
});
req.go();
},
},
getSubscriptionStatus: function(username) {
var req = new enyo.Ajax({
- url: baseURL + '/feedinfo/' + username,
+ url: baseURL + '/status/' + username,
method: 'POST',
postBody: {
username: blerg.API.username
onSetTitle: "setTitle",
onPostVisibility: "postVisibilityUpdate",
onReload: "sendReload",
- onShowChangePassword: "showChangePassword",
- onClearFeedStatus: "clearFeedStatus"
+ onShowChangePassword: "showChangePassword"
},
components: [
{classes: "blerg-header", components: [
},
showChangePassword: function() {
this.$.passwdDialog.show();
- },
- clearFeedStatus: function() {
- this.$.controls.waterfall('onClearFeedStatus');
}
});
handlers: {
onLogin: "login",
onLogout: "logout",
- onPostVisibility: "postVisibilityUpdate",
- onClearFeedStatus: "clearFeedStatus"
+ onPostVisibility: "postVisibilityUpdate"
},
components: [
{name: "loggedOutControls", components: [
{tag: null, content: "."}
]},
{classes: "blerg-controls-toolbar", components: [
- {kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"},
+ {name: "mentionButton", kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"},
{name: "feedButton", kind: "onyx.Button", classes: "feed-button", content: "Stalk Your Victims", onclick: "feedClicked"},
{name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
]},
]},
{name: "api", kind: "blerg.API",
- onFeedInfo: "gotFeedInfo"}
+ onStatus: "gotStatus"},
+ {kind: "Signals",
+ onClearNotification: "clearNotification"}
],
showRSS: function(url) {
this.$.rssButton.show();
this.$.userlink.setContent('@' + inEvent.username);
this.username = inEvent.username;
- this.updateFeedInfo();
+ this.updateStatus();
this.feedStatusUpdateInterval = setInterval(function() {
- this.updateFeedInfo();
+ this.updateStatus();
}.bind(this), 900000);
},
logout: function(inSender, inEvent) {
this.postShowing = inEvent.showing;
this.$.spewButton.addRemoveClass('active', inEvent.showing);
},
- updateFeedInfo: function() {
- this.$.api.getFeedInfo();
+ updateStatus: function() {
+ this.$.api.getStatus();
},
- gotFeedInfo: function(inSender, inEvent) {
- this.$.feedButton.addRemoveClass('new', inEvent.new > 0);
- if (inEvent.new > 0) {
- this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.new + ')');
- } else {
- this.$.feedButton.setContent('Stalk Your Victims');
+ gotStatus: function(inSender, inEvent) {
+ if ('mentioned' in inEvent) {
+ this.$.mentionButton.addRemoveClass('new', inEvent.mentioned);
+ }
+ if ('feed_new' in inEvent) {
+ this.$.feedButton.addRemoveClass('new', inEvent.feed_new > 0);
+ if (inEvent.feed_new > 0) {
+ this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.feed_new + ')');
+ } else {
+ this.$.feedButton.setContent('Stalk Your Victims');
+ }
}
},
chatterClicked: function() {
window.location.href = '/#/feed';
this.bubble('onNavigate');
},
- clearFeedStatus: function() {
- this.gotFeedInfo(this, {new: 0});
+ clearNotification: function(inSender, inEvent) {
+ if (inEvent.type == 'feed') {
+ this.gotStatus(this, {feed_new: 0});
+ } else if (inEvent.type == 'mentioned') {
+ this.gotStatus(this, {mentioned: false});
+ }
}
});
{name: "records"},
{name: "spinner", kind: "OldSchoolSpinner", showing: false},
{name: "api", kind: "blerg.API",
- onItemsLoaded: "itemsLoaded"}
+ onItemsLoaded: "itemsLoaded",
+ onClearStatus: "clearStatus"}
],
statics: {
locationDetect: function(l) {
},
itemsLoaded: function(inSender, inEvent) {
this.addItems(inEvent.entries);
- this.bubble('onClearFeedStatus');
+ this.$.api.clearStatus('feed');
+ },
+ clearStatus: function(inSender, inEvent) {
+ if (inEvent.type == 'feed' && inEvent.status == 'success') {
+ enyo.Signals.send('onClearNotification', {type: inEvent.type});
+ }
}
});
{name: "records"},
{name: "spinner", kind: "OldSchoolSpinner", showing: false},
{name: "api", kind: "blerg.API",
- onItemsLoaded: "itemsLoaded"}
+ onItemsLoaded: "itemsLoaded",
+ onClearStatus: "clearStatus"}
],
statics: {
locationDetect: function(l) {
},
itemsLoaded: function(inSender, inEvent) {
this.addItems(inEvent.entries);
+ if (this.type == 'ref' && blerg.API.loggedIn && blerg.API.username == this.tag) {
+ this.$.api.clearStatus('mentioned');
+ }
+ },
+ clearStatus: function(inSender, inEvent) {
+ if (inEvent.type == 'mentioned' && inEvent.status == 'success') {
+ enyo.Signals.send('onClearNotification', {type: inEvent.type});
+ }
}
});