mirror of https://github.com/vector-im/riot-web
Merge pull request #9086 from yaya-usman/favouriteMessages_Panel
Starred_Messages_Feature_Contd_II/Outreachypull/28788/head^2
commit
81653cf5fd
|
@ -77,10 +77,12 @@ interface IState {
|
||||||
sublists: ITagMap;
|
sublists: ITagMap;
|
||||||
currentRoomId?: string;
|
currentRoomId?: string;
|
||||||
suggestedRooms: ISuggestedRoom[];
|
suggestedRooms: ISuggestedRoom[];
|
||||||
|
feature_favourite_messages: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TAG_ORDER: TagID[] = [
|
export const TAG_ORDER: TagID[] = [
|
||||||
DefaultTagID.Invite,
|
DefaultTagID.Invite,
|
||||||
|
DefaultTagID.SavedItems,
|
||||||
DefaultTagID.Favourite,
|
DefaultTagID.Favourite,
|
||||||
DefaultTagID.DM,
|
DefaultTagID.DM,
|
||||||
DefaultTagID.Untagged,
|
DefaultTagID.Untagged,
|
||||||
|
@ -351,6 +353,11 @@ const TAG_AESTHETICS: ITagAestheticsMap = {
|
||||||
isInvite: false,
|
isInvite: false,
|
||||||
defaultHidden: false,
|
defaultHidden: false,
|
||||||
},
|
},
|
||||||
|
[DefaultTagID.SavedItems]: {
|
||||||
|
sectionLabel: _td("Saved Items"),
|
||||||
|
isInvite: false,
|
||||||
|
defaultHidden: false,
|
||||||
|
},
|
||||||
[DefaultTagID.DM]: {
|
[DefaultTagID.DM]: {
|
||||||
sectionLabel: _td("People"),
|
sectionLabel: _td("People"),
|
||||||
isInvite: false,
|
isInvite: false,
|
||||||
|
@ -392,6 +399,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
private dispatcherRef;
|
private dispatcherRef;
|
||||||
private roomStoreToken: fbEmitter.EventSubscription;
|
private roomStoreToken: fbEmitter.EventSubscription;
|
||||||
private treeRef = createRef<HTMLDivElement>();
|
private treeRef = createRef<HTMLDivElement>();
|
||||||
|
private favouriteMessageWatcher: string;
|
||||||
|
|
||||||
static contextType = MatrixClientContext;
|
static contextType = MatrixClientContext;
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
@ -402,6 +410,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
this.state = {
|
this.state = {
|
||||||
sublists: {},
|
sublists: {},
|
||||||
suggestedRooms: SpaceStore.instance.suggestedRooms,
|
suggestedRooms: SpaceStore.instance.suggestedRooms,
|
||||||
|
feature_favourite_messages: SettingsStore.getValue("feature_favourite_messages"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,12 +419,17 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
this.roomStoreToken = RoomViewStore.instance.addListener(this.onRoomViewStoreUpdate);
|
this.roomStoreToken = RoomViewStore.instance.addListener(this.onRoomViewStoreUpdate);
|
||||||
SpaceStore.instance.on(UPDATE_SUGGESTED_ROOMS, this.updateSuggestedRooms);
|
SpaceStore.instance.on(UPDATE_SUGGESTED_ROOMS, this.updateSuggestedRooms);
|
||||||
RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.updateLists);
|
RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.updateLists);
|
||||||
|
this.favouriteMessageWatcher =
|
||||||
|
SettingsStore.watchSetting("feature_favourite_messages", null, (...[,,, value]) => {
|
||||||
|
this.setState({ feature_favourite_messages: value });
|
||||||
|
});
|
||||||
this.updateLists(); // trigger the first update
|
this.updateLists(); // trigger the first update
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
SpaceStore.instance.off(UPDATE_SUGGESTED_ROOMS, this.updateSuggestedRooms);
|
SpaceStore.instance.off(UPDATE_SUGGESTED_ROOMS, this.updateSuggestedRooms);
|
||||||
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this.updateLists);
|
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this.updateLists);
|
||||||
|
SettingsStore.unwatchSetting(this.favouriteMessageWatcher);
|
||||||
defaultDispatcher.unregister(this.dispatcherRef);
|
defaultDispatcher.unregister(this.dispatcherRef);
|
||||||
if (this.roomStoreToken) this.roomStoreToken.remove();
|
if (this.roomStoreToken) this.roomStoreToken.remove();
|
||||||
}
|
}
|
||||||
|
@ -545,6 +559,28 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private renderFavoriteMessagesList(): ReactComponentElement<typeof ExtraTile>[] {
|
||||||
|
const avatar = (
|
||||||
|
<RoomAvatar
|
||||||
|
oobData={{
|
||||||
|
name: "Favourites",
|
||||||
|
}}
|
||||||
|
width={32}
|
||||||
|
height={32}
|
||||||
|
resizeMethod="crop"
|
||||||
|
/>);
|
||||||
|
|
||||||
|
return [
|
||||||
|
<ExtraTile
|
||||||
|
isMinimized={this.props.isMinimized}
|
||||||
|
isSelected={false}
|
||||||
|
displayName="Favourite Messages"
|
||||||
|
avatar={avatar}
|
||||||
|
onClick={() => ""}
|
||||||
|
key="favMessagesTile_key"
|
||||||
|
/>,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private renderSublists(): React.ReactElement[] {
|
private renderSublists(): React.ReactElement[] {
|
||||||
// show a skeleton UI if the user is in no rooms and they are not filtering and have no suggested rooms
|
// show a skeleton UI if the user is in no rooms and they are not filtering and have no suggested rooms
|
||||||
|
@ -558,6 +594,12 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
extraTiles = this.renderSuggestedRooms();
|
extraTiles = this.renderSuggestedRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.feature_favourite_messages && orderedTagId === DefaultTagID.SavedItems) {
|
||||||
|
extraTiles = this.renderFavoriteMessagesList();
|
||||||
|
} else {
|
||||||
|
extraTiles = null;
|
||||||
|
}
|
||||||
|
|
||||||
const aesthetics = TAG_AESTHETICS[orderedTagId];
|
const aesthetics = TAG_AESTHETICS[orderedTagId];
|
||||||
if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`);
|
if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`);
|
||||||
|
|
||||||
|
@ -582,7 +624,6 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
) {
|
) {
|
||||||
forceExpanded = true;
|
forceExpanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The cost of mounting/unmounting this component offsets the cost
|
// The cost of mounting/unmounting this component offsets the cost
|
||||||
// of keeping it in the DOM and hiding it when it is not required
|
// of keeping it in the DOM and hiding it when it is not required
|
||||||
return <RoomSublist
|
return <RoomSublist
|
||||||
|
|
|
@ -527,7 +527,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderMenu(): React.ReactElement {
|
private renderMenu(): React.ReactElement {
|
||||||
if (this.props.tagId === DefaultTagID.Suggested) return null; // not sortable
|
if (this.props.tagId === DefaultTagID.Suggested || this.props.tagId === DefaultTagID.SavedItems) return null; // not sortable
|
||||||
|
|
||||||
let contextMenu = null;
|
let contextMenu = null;
|
||||||
if (this.state.contextMenuPosition) {
|
if (this.state.contextMenuPosition) {
|
||||||
|
|
|
@ -1803,6 +1803,7 @@
|
||||||
"Explore public rooms": "Explore public rooms",
|
"Explore public rooms": "Explore public rooms",
|
||||||
"Add room": "Add room",
|
"Add room": "Add room",
|
||||||
"Invites": "Invites",
|
"Invites": "Invites",
|
||||||
|
"Saved Items": "Saved Items",
|
||||||
"Low priority": "Low priority",
|
"Low priority": "Low priority",
|
||||||
"System Alerts": "System Alerts",
|
"System Alerts": "System Alerts",
|
||||||
"Historical": "Historical",
|
"Historical": "Historical",
|
||||||
|
|
|
@ -23,11 +23,13 @@ export enum DefaultTagID {
|
||||||
DM = "im.vector.fake.direct",
|
DM = "im.vector.fake.direct",
|
||||||
ServerNotice = "m.server_notice",
|
ServerNotice = "m.server_notice",
|
||||||
Suggested = "im.vector.fake.suggested",
|
Suggested = "im.vector.fake.suggested",
|
||||||
|
SavedItems = "im.vector.fake.saved_items",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OrderedDefaultTagIDs = [
|
export const OrderedDefaultTagIDs = [
|
||||||
DefaultTagID.Invite,
|
DefaultTagID.Invite,
|
||||||
DefaultTagID.Favourite,
|
DefaultTagID.Favourite,
|
||||||
|
DefaultTagID.SavedItems,
|
||||||
DefaultTagID.DM,
|
DefaultTagID.DM,
|
||||||
DefaultTagID.Untagged,
|
DefaultTagID.Untagged,
|
||||||
DefaultTagID.LowPriority,
|
DefaultTagID.LowPriority,
|
||||||
|
|
Loading…
Reference in New Issue