Make onClick be a context menu for presence
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
03800b7476
commit
c483717282
1 changed files with 32 additions and 18 deletions
|
@ -23,6 +23,7 @@ import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import Presence from "../../../Presence";
|
import Presence from "../../../Presence";
|
||||||
import dispatcher from "../../../dispatcher";
|
import dispatcher from "../../../dispatcher";
|
||||||
import UserSettingsStore from "../../../UserSettingsStore";
|
import UserSettingsStore from "../../../UserSettingsStore";
|
||||||
|
import * as ContextualMenu from "../../structures/ContextualMenu";
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MemberPresenceAvatar',
|
displayName: 'MemberPresenceAvatar',
|
||||||
|
@ -44,8 +45,10 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
const presenceState = this.props.member.user.presence;
|
const presenceState = this.props.member.user.presence;
|
||||||
|
const presenceMessage = this.props.member.user.presenceStatusMsg;
|
||||||
return {
|
return {
|
||||||
status: presenceState,
|
status: presenceState,
|
||||||
|
message: presenceMessage,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -78,27 +81,38 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick: function() {
|
onStatusChange: function(newStatus) {
|
||||||
if (Presence.getState() === "online") {
|
console.log(this.state);
|
||||||
Presence.setState("unavailable", "This is a message", true);
|
console.log(newStatus);
|
||||||
} else {
|
},
|
||||||
Presence.stopMaintainingStatus();
|
|
||||||
}
|
|
||||||
console.log("CLICK");
|
|
||||||
|
|
||||||
const presenceState = this.props.member.user.presence;
|
onClick: function(e) {
|
||||||
const presenceLastActiveAgo = this.props.member.user.lastActiveAgo;
|
const PresenceContextMenu = sdk.getComponent('context_menus.PresenceContextMenu');
|
||||||
const presenceLastTs = this.props.member.user.lastPresenceTs;
|
const elementRect = e.target.getBoundingClientRect();
|
||||||
const presenceCurrentlyActive = this.props.member.user.currentlyActive;
|
|
||||||
const presenceMessage = this.props.member.user.presenceStatusMsg;
|
|
||||||
|
|
||||||
console.log({
|
// The window X and Y offsets are to adjust position when zoomed in to page
|
||||||
presenceState,
|
const x = (elementRect.left + window.pageXOffset) - (elementRect.width / 2) + 3;
|
||||||
presenceLastActiveAgo,
|
const chevronOffset = 12;
|
||||||
presenceLastTs,
|
let y = elementRect.top + (elementRect.height / 2) + window.pageYOffset;
|
||||||
presenceCurrentlyActive,
|
y = y - (chevronOffset + 4); // where 4 is 1/4 the height of the chevron
|
||||||
presenceMessage,
|
|
||||||
|
const self = this;
|
||||||
|
ContextualMenu.createMenu(PresenceContextMenu, {
|
||||||
|
chevronOffset: chevronOffset,
|
||||||
|
chevronFace: 'bottom',
|
||||||
|
left: x,
|
||||||
|
top: y,
|
||||||
|
menuWidth: 300,
|
||||||
|
currentStatus: this.state.status,
|
||||||
|
onChange: this.onStatusChange,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
|
// const presenceState = this.props.member.user.presence;
|
||||||
|
// const presenceLastActiveAgo = this.props.member.user.lastActiveAgo;
|
||||||
|
// const presenceLastTs = this.props.member.user.lastPresenceTs;
|
||||||
|
// const presenceCurrentlyActive = this.props.member.user.currentlyActive;
|
||||||
|
// const presenceMessage = this.props.member.user.presenceStatusMsg;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
Loading…
Reference in a new issue