Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Remove presence management
Browse files Browse the repository at this point in the history
The feature is incredibly buggy and doesn't work as expected due to server behaviour and client interaction. One of the major problems is the constantly confused presence state - this is caused by the mobile apps conflicting on the state of the web app, causing it to consider the user offline or online (and rarely away) depending on how riot-android/ios is behaving at the time.

This reverts two PRs:
* #1620
* #1482

The changes to the context menu positioning were not reverted as they are useful outside of presence management.

Signed-off-by: Travis Ralston <travpc@gmail.com>
  • Loading branch information
turt2live authored and dbkr committed Apr 12, 2018
1 parent 760f21b commit 91a4139
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 205 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 @@ -251,15 +251,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

0 comments on commit 91a4139

Please sign in to comment.