Skip to content

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:
* matrix-org#1620
* matrix-org#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 committed Dec 25, 2017
1 parent b5f6d97 commit cc5eb77
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 206 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
39 changes: 4 additions & 35 deletions src/Presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,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 @@ -86,37 +72,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 All @@ -125,8 +95,7 @@ class Presence {
this.setState("unavailable");
}

_onUserActivity(payload) {
if (payload.action === "sync_state" || payload.action === "self_presence_updated") return;
_onUserActivity() {
this._resetTimer();
}

Expand Down
168 changes: 0 additions & 168 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 @@ -238,15 +238,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 @@ -157,6 +157,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 cc5eb77

Please sign in to comment.