This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 830
Starred Messages View Screen #9182
Closed
Closed
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
57a6de5
removed dead code related favorite messages panel
yaya-usman f92d917
correct code nits
yaya-usman 60e62a0
updated code: fetching of messages asynchronously
yaya-usman d7f8a7e
display sender details correctly and removed edit button from message…
yaya-usman 934d408
moved FavMessages related codes to one folder and added FavMessagesVi…
yaya-usman 914e58f
resolved conflict
yaya-usman 4b4bf4b
added the searchFilter, sort and clear all functionality
yaya-usman 7d404b1
filter search terms and highlight
yaya-usman dc16558
Merge branch 'develop' of https://github.com/yaya-usman/matrix-react-…
yaya-usman 5ffa8b3
typescript check error fix
yaya-usman 9450fbf
Added clear all confirmation modal
yaya-usman bbca082
written tests for Favourite Message View
yaya-usman 1874484
Merge branch 'develop' of https://github.com/yaya-usman/matrix-react-…
yaya-usman 7cc7a99
resolve code nits
yaya-usman 97e39ed
update favourite messages related test in MessageActionBar.tsx
yaya-usman 64b7c12
resolve typescript check problem
yaya-usman 7d04db3
Update src/components/structures/FavouriteMessagesView/FavouriteMessa…
yaya-usman b6ba7b9
Update src/hooks/useFavouriteMessages.ts
yaya-usman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_FavMessagesHeader { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
flex: 0 0 50px; | ||
border-bottom: 1px solid $primary-hairline-color; | ||
background-color: $background; | ||
z-index: 999; | ||
} | ||
|
||
.mx_FavMessagesHeader_Wrapper { | ||
height: 44px; | ||
display: flex; | ||
align-items: center; | ||
min-width: 0; | ||
margin: 0 20px 0 16px; | ||
padding-top: 8px; | ||
border-bottom: 1px solid $system; | ||
justify-content: space-between; | ||
|
||
.mx_FavMessagesHeader_Wrapper_left { | ||
display: flex; | ||
align-items: center; | ||
flex: 0.4; | ||
|
||
& > span { | ||
color: $primary-content; | ||
font-weight: $font-semi-bold; | ||
font-size: $font-18px; | ||
margin: 0 8px; | ||
} | ||
} | ||
|
||
.mx_FavMessagesHeader_Wrapper_right { | ||
display: flex; | ||
align-items: center; | ||
flex: 0.6; | ||
justify-content: flex-end; | ||
} | ||
} | ||
|
||
.mx_FavMessagesHeader_sortButton::before { | ||
mask-image: url('$(res)/img/element-icons/room/sort-twoway.svg'); | ||
} | ||
|
||
.mx_FavMessagesHeader_clearAllButton::before { | ||
mask-image: url('$(res)/img/element-icons/room/clear-all.svg'); | ||
} | ||
|
||
.mx_FavMessagesHeader_cancelButton { | ||
background-color: $alert; | ||
mask: url('$(res)/img/cancel.svg'); | ||
mask-repeat: no-repeat; | ||
mask-position: center; | ||
mask-size: 17px; | ||
padding: 9px; | ||
margin: 0 12px 0 3px; | ||
cursor: pointer; | ||
} | ||
|
||
.mx_FavMessagesHeader_Search { | ||
width: 70%; | ||
} | ||
|
||
.mx_FavouriteMessages_emptyMarker { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 25px; | ||
font-weight: 600; | ||
} | ||
|
||
.mx_FavouriteMessages_scrollPanel { | ||
margin-top: 25px; | ||
} | ||
|
||
.mx_ClearDialog { | ||
width: 100%; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/components/structures/FavouriteMessagesView/ConfirmClearDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React, { FC } from 'react'; | ||
|
||
import useFavouriteMessages from '../../../hooks/useFavouriteMessages'; | ||
import { _t } from '../../../languageHandler'; | ||
import BaseDialog from "../../views/dialogs/BaseDialog"; | ||
import { IDialogProps } from '../../views/dialogs/IDialogProps'; | ||
import DialogButtons from "../../views/elements/DialogButtons"; | ||
|
||
/* | ||
* A dialog for confirming a clearing of starred messages. | ||
*/ | ||
const ConfirmClearDialog: FC<IDialogProps> = (props: IDialogProps) => { | ||
const { clearFavouriteMessages } = useFavouriteMessages(); | ||
|
||
const onConfirmClick = () => { | ||
clearFavouriteMessages(); | ||
props.onFinished(); | ||
}; | ||
|
||
return ( | ||
<BaseDialog | ||
className="mx_TextInputDialog mx_ClearDialog" | ||
onFinished={props.onFinished} | ||
title={_t("Confirm Removal")} | ||
> | ||
<div className="mx_Dialog_content"> | ||
<div className="mx_TextInputDialog_label"> | ||
<span> { _t("Are you sure you wish to clear all your starred messages? ") } </span> | ||
</div> | ||
</div> | ||
<DialogButtons | ||
primaryButton={_t("Confirm")} | ||
onPrimaryButtonClick={onConfirmClick} | ||
onCancel={props.onFinished} | ||
hasCancel={true} | ||
/> | ||
</BaseDialog> | ||
); | ||
}; | ||
|
||
export default ConfirmClearDialog; | ||
111 changes: 111 additions & 0 deletions
111
src/components/structures/FavouriteMessagesView/FavouriteMessageTile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React, { FC } from "react"; | ||
import { MatrixEvent } from "matrix-js-sdk/src/models/event"; | ||
|
||
import RoomContext from "../../../contexts/RoomContext"; | ||
import SettingsStore from "../../../settings/SettingsStore"; | ||
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks'; | ||
import DateSeparator from "../../views/messages/DateSeparator"; | ||
import EventTile from "../../views/rooms/EventTile"; | ||
import { shouldFormContinuation } from "../MessagePanel"; | ||
import { wantsDateSeparator } from "../../../DateUtils"; | ||
import { haveRendererForEvent } from "../../../events/EventTileFactory"; | ||
|
||
interface IProps { | ||
// an event result object | ||
result: MatrixEvent; | ||
// href for the highlights in this result | ||
resultLink: string; | ||
// a list of strings to be highlighted in the results | ||
searchHighlights?: string[]; | ||
onHeightChanged?: () => void; | ||
permalinkCreator?: RoomPermalinkCreator; | ||
//a list containing the saved items events | ||
timeline: MatrixEvent[]; | ||
} | ||
|
||
const FavouriteMessageTile: FC<IProps> = (props: IProps) => { | ||
let context!: React.ContextType<typeof RoomContext>; | ||
|
||
const result = props.result; | ||
const eventId = result.getId(); | ||
|
||
const ts1 = result?.getTs(); | ||
const ret = [<DateSeparator key={ts1 + "-search"} roomId={(result.getRoomId())!} ts={ts1} />]; | ||
const layout = SettingsStore.getValue("layout"); | ||
const isTwelveHour = SettingsStore.getValue("showTwelveHourTimestamps"); | ||
const alwaysShowTimestamps = SettingsStore.getValue("alwaysShowTimestamps"); | ||
const threadsEnabled = SettingsStore.getValue("feature_thread"); | ||
|
||
for (let j = 0; j < props?.timeline.length; j++) { | ||
const mxEv = props?.timeline[j]; | ||
const highlights = props?.searchHighlights; | ||
|
||
if (haveRendererForEvent(mxEv, context?.showHiddenEvents)) { | ||
// do we need a date separator since the last event? | ||
const prevEv = props.timeline[j - 1]; | ||
// is this a continuation of the previous message? | ||
const continuation = prevEv && | ||
!wantsDateSeparator((prevEv.getDate())!, mxEv.getDate()) && | ||
shouldFormContinuation( | ||
prevEv, | ||
mxEv, | ||
context?.showHiddenEvents, | ||
threadsEnabled, | ||
); | ||
|
||
let lastInSection = true; | ||
const nextEv = props?.timeline[j + 1]; | ||
if (nextEv) { | ||
const willWantDateSeparator = wantsDateSeparator((mxEv.getDate())!, nextEv.getDate()); | ||
lastInSection = ( | ||
willWantDateSeparator || | ||
mxEv.getSender() !== nextEv.getSender() || | ||
!shouldFormContinuation( | ||
mxEv, | ||
nextEv, | ||
context?.showHiddenEvents, | ||
threadsEnabled, | ||
) | ||
); | ||
} | ||
|
||
ret.push( | ||
<EventTile | ||
key={`${eventId}+${j}`} | ||
mxEvent={mxEv} | ||
layout={layout} | ||
highlights={highlights} | ||
permalinkCreator={props.permalinkCreator} | ||
highlightLink={props.resultLink} | ||
onHeightChanged={props.onHeightChanged} | ||
isTwelveHour={isTwelveHour} | ||
alwaysShowTimestamps={alwaysShowTimestamps} | ||
lastInSection={lastInSection} | ||
continuation={continuation} | ||
/>, | ||
); | ||
} | ||
} | ||
|
||
return <li data-scroll-tokens={eventId}> | ||
<ol>{ ret }</ol> | ||
</li>; | ||
}; | ||
|
||
export default FavouriteMessageTile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not export but default and use named exports instead |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not export but default and use named exports instead