Skip to content

Commit

Permalink
Merge pull request #1676 from turt2live/travis/remove-presence
Browse files Browse the repository at this point in the history
Remove presence management
  • Loading branch information
ara4n committed Apr 12, 2018
2 parents 9794526 + fe2cbc5 commit d082758
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 211 deletions.
1 change: 0 additions & 1 deletion src/MatrixClientPeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class MatrixClientPeg {
const opts = utils.deepCopy(this.opts);
// the react sdk doesn't work without this, so don't allow
opts.pendingEventOrdering = "detached";
opts.disablePresence = true; // we do this manually

try {
const promise = this.matrixClient.store.startup();
Expand Down
36 changes: 3 additions & 33 deletions src/Presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,13 @@ class Presence {
return this.state;
}

/**
* Get the current status message.
* @returns {String} the status message, may be null
*/
getStatusMessage() {
return this.statusMessage;
}

/**
* Set the presence state.
* If the state has changed, the Home Server will be notified.
* @param {string} newState the new presence state (see PRESENCE enum)
* @param {String} statusMessage an optional status message for the presence
* @param {boolean} maintain true to have this status maintained by this tracker
*/
setState(newState, statusMessage=null, maintain=false) {
if (this.maintain) {
// Don't update presence if we're maintaining a particular status
return;
}
if (newState === this.state && statusMessage === this.statusMessage) {
setState(newState) {
if (newState === this.state) {
return;
}
if (PRESENCE_STATES.indexOf(newState) === -1) {
Expand All @@ -87,37 +73,21 @@ class Presence {
return;
}
const old_state = this.state;
const old_message = this.statusMessage;
this.state = newState;
this.statusMessage = statusMessage;
this.maintain = maintain;

if (MatrixClientPeg.get().isGuest()) {
return; // don't try to set presence when a guest; it won't work.
}

const updateContent = {
presence: this.state,
status_msg: this.statusMessage ? this.statusMessage : '',
};

const self = this;
MatrixClientPeg.get().setPresence(updateContent).done(function() {
MatrixClientPeg.get().setPresence(this.state).done(function() {
console.log("Presence: %s", newState);

// We have to dispatch because the js-sdk is unreliable at telling us about our own presence
dis.dispatch({action: "self_presence_updated", statusInfo: updateContent});
}, function(err) {
console.error("Failed to set presence: %s", err);
self.state = old_state;
self.statusMessage = old_message;
});
}

stopMaintainingStatus() {
this.maintain = false;
}

/**
* Callback called when the user made no action on the page for UNAVAILABLE_TIME ms.
* @private
Expand Down
169 changes: 0 additions & 169 deletions src/components/views/avatars/MemberPresenceAvatar.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/views/rooms/MessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ export default class MessageComposer extends React.Component {
render() {
const me = this.props.room.getMember(MatrixClientPeg.get().credentials.userId);
const uploadInputStyle = {display: 'none'};
const MemberPresenceAvatar = sdk.getComponent('avatars.MemberPresenceAvatar');
const MemberAvatar = sdk.getComponent('avatars.MemberAvatar');
const TintableSvg = sdk.getComponent("elements.TintableSvg");
const MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput");

const controls = [];

controls.push(
<div key="controls_avatar" className="mx_MessageComposer_avatar">
<MemberPresenceAvatar member={me} width={24} height={24} />
<MemberAvatar member={me} width={24} height={24} />
</div>,
);

Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"%(widgetName)s widget modified by %(senderName)s": "%(widgetName)s widget modified by %(senderName)s",
"%(widgetName)s widget added by %(senderName)s": "%(widgetName)s widget added by %(senderName)s",
"%(widgetName)s widget removed by %(senderName)s": "%(widgetName)s widget removed by %(senderName)s",
"Message Pinning": "Message Pinning",
"%(displayName)s is typing": "%(displayName)s is typing",
"%(names)s and %(count)s others are typing|other": "%(names)s and %(count)s others are typing",
"%(names)s and %(count)s others are typing|one": "%(names)s and one other is typing",
Expand Down
6 changes: 0 additions & 6 deletions src/settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ export const SETTINGS = {
supportedLevels: LEVELS_FEATURE,
default: false,
},
"feature_presence_management": {
isFeature: true,
displayName: _td("Presence Management"),
supportedLevels: LEVELS_FEATURE,
default: false,
},
"feature_tag_panel": {
isFeature: true,
displayName: _td("Tag Panel"),
Expand Down

0 comments on commit d082758

Please sign in to comment.