-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove some dependencies from PinnedMessagePopup #16435
Open
iurimatias
wants to merge
3
commits into
master
Choose a base branch
from
refactor/pinned_messages_popup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+258
−8
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
import QtQuick 2.14 | ||
import QtQuick.Controls 2.14 | ||
import QtQuick.Layouts 1.14 | ||
|
||
import StatusQ.Controls 0.1 | ||
import StatusQ.Core.Theme 0.1 | ||
import StatusQ.Components 0.1 | ||
|
||
import Storybook 1.0 | ||
import Models 1.0 | ||
|
||
import utils 1.0 | ||
import shared.views.chat 1.0 | ||
import shared.status 1.0 | ||
import AppLayouts.Chat.popups 1.0 | ||
|
||
SplitView { | ||
QtObject { | ||
id: d | ||
} | ||
|
||
Logs { id: logs } | ||
|
||
QtObject { | ||
id: d_msg | ||
|
||
readonly property var messagesModel: ListModel { | ||
ListElement { | ||
timestamp: 1656937930123 | ||
senderId: "zq123456789" | ||
senderDisplayName: "simon" | ||
profileImage: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0BhCExPynn1gWf9bx498P7/ | ||
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC" | ||
contentType: StatusMessage.ContentType.Text | ||
message: "Hello, this is awesome! Feels like decentralized Discord! And it even supports HTML markup, like <b>bold</b>, <i>italics</i> or <u>underline</u>" | ||
isContact: true | ||
isAReply: false | ||
trustIndicator: StatusContactVerificationIcons.TrustedType.Verified | ||
outgoingStatus: StatusMessage.OutgoingStatus.Delivered | ||
} | ||
ListElement { | ||
timestamp: 1657937930135 | ||
senderId: "zqABCDEFG" | ||
senderDisplayName: "Mark Cuban" | ||
contentType: StatusMessage.ContentType.Text | ||
message: "I know a lot of you really seem to get off or be validated by arguing with strangers online but please know it's a complete waste of your time and energy" | ||
isContact: false | ||
isAReply: false | ||
trustIndicator: StatusContactVerificationIcons.TrustedType.Untrustworthy | ||
outgoingStatus: StatusMessage.OutgoingStatus.Delivered | ||
} | ||
ListElement { | ||
timestamp: 1667937930159 | ||
senderId: "zqdeadbeef" | ||
senderDisplayName: "replicator.stateofus.eth" | ||
contentType: StatusMessage.ContentType.Text | ||
message: "Test reply; the original text above should have a horizontal gradient mask" | ||
isContact: true | ||
isAReply: true | ||
trustIndicator: StatusContactVerificationIcons.TrustedType.None | ||
outgoingStatus: StatusMessage.OutgoingStatus.Delivered | ||
} | ||
} | ||
readonly property var colorHash: ListModel { | ||
ListElement { colorId: 13; segmentLength: 5 } | ||
ListElement { colorId: 31; segmentLength: 5 } | ||
ListElement { colorId: 10; segmentLength: 1 } | ||
} | ||
} | ||
|
||
QtObject { | ||
id: mockMessageStore | ||
// redo it, use first message as pinned message from d_msg.messagesModel the one whose timestamp is 1656937930123 | ||
property ListModel pinnedMessagesModel: ListModel { | ||
} | ||
|
||
function getMessageByIndexAsJson(index) { | ||
if (index >= 0 && index < pinnedMessagesModel.count) { | ||
return JSON.stringify(pinnedMessagesModel.get(index)) | ||
} | ||
return "{}" | ||
} | ||
|
||
function unpinMessage(messageId) { | ||
console.log("Unpinning message:", messageId) | ||
} | ||
|
||
property bool amIChatAdmin: false | ||
property int chatType: Constants.chatType.oneToOne | ||
|
||
function setEditModeOff(messageId) { | ||
console.log("Setting edit mode off for message:", messageId) | ||
} | ||
|
||
function setEditModeOn(messageId) { | ||
console.log("Setting edit mode on for message:", messageId) | ||
} | ||
|
||
function warnAndDeleteMessage(messageId) { | ||
console.log("Warning and deleting message:", messageId) | ||
} | ||
|
||
function toggleReaction(messageId, emojiId) { | ||
console.log("Toggling reaction for message:", messageId, "with emoji:", emojiId) | ||
} | ||
|
||
function markMessageAsUnread(messageId) { | ||
console.log("Marking message as unread:", messageId) | ||
} | ||
|
||
function pinMessage(messageId) { | ||
console.log("Pinning message:", messageId) | ||
} | ||
} | ||
|
||
QtObject { | ||
id: mockRootStore | ||
property var messageStore: mockMessageStore | ||
} | ||
|
||
SplitView { | ||
orientation: Qt.Vertical | ||
SplitView.fillWidth: true | ||
|
||
Rectangle { | ||
SplitView.fillWidth: true | ||
SplitView.fillHeight: true | ||
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor | ||
clip: true | ||
|
||
ColumnLayout { | ||
anchors.centerIn: parent | ||
spacing: 10 | ||
|
||
Button { | ||
text: "Open Empty Pinned Messages Popup" | ||
onClicked: { | ||
mockMessageStore.pinnedMessagesModel.clear() | ||
pinnedMessagesPopup.messageToPin = "" | ||
pinnedMessagesPopup.open() | ||
} | ||
} | ||
|
||
Button { | ||
text: "Open Pinned Messages Popup (2 messages)" | ||
onClicked: { | ||
mockMessageStore.pinnedMessagesModel.clear() | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(0)) | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(1)) | ||
pinnedMessagesPopup.messageToPin = "" | ||
pinnedMessagesPopup.open() | ||
} | ||
} | ||
|
||
Button { | ||
text: "Open Full Pinned Messages Popup (3 messages)" | ||
onClicked: { | ||
mockMessageStore.pinnedMessagesModel.clear() | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(0)) | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(1)) | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(2)) | ||
pinnedMessagesPopup.messageToPin = "" | ||
pinnedMessagesPopup.open() | ||
} | ||
} | ||
|
||
Button { | ||
text: "Open Unpin Messages Popup (3 messages + messageToPin)" | ||
onClicked: { | ||
mockMessageStore.pinnedMessagesModel.clear() | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(0)) | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(1)) | ||
mockMessageStore.pinnedMessagesModel.append(d_msg.messagesModel.get(2)) | ||
pinnedMessagesPopup.messageToPin = "This is a message to pin" | ||
pinnedMessagesPopup.open() | ||
} | ||
} | ||
} | ||
|
||
PinnedMessagesPopup { | ||
id: pinnedMessagesPopup | ||
store: mockRootStore | ||
messageStore: d_msg | ||
pinnedMessagesModel: mockMessageStore.pinnedMessagesModel | ||
chatId: "chat1" | ||
|
||
property var chatContentModule: QtObject { | ||
property var chatDetails: QtObject { | ||
property bool canPostReactions: true | ||
property bool canPost: true | ||
property bool canView: true | ||
} | ||
property var pinnedMessagesModel: mockMessageStore.pinnedMessagesModel | ||
} | ||
|
||
property var usersStore: QtObject { | ||
property var usersModel: [] | ||
} | ||
|
||
property var contactsStore: QtObject { | ||
function getProfileContext(publicKey, myPublicKey, isBridgedAccount) { | ||
return { | ||
profileType: Constants.profileType.regular, | ||
trustStatus: Constants.trustStatus.unknown, | ||
contactType: Constants.contactType.nonContact, | ||
ensVerified: false, | ||
onlineStatus: Constants.onlineStatus.unknown, | ||
hasLocalNickname: false | ||
} | ||
} | ||
} | ||
|
||
property var emojiPopup: null | ||
property var stickersPopup: null | ||
|
||
onPinMessageRequested: (messageId) => { | ||
logs.logEvent("Pin message requested:", messageId) | ||
} | ||
onUnpinMessageRequested: (messageId) => { | ||
logs.logEvent("Unpin message requested:", messageId) | ||
} | ||
onJumpToMessageRequested: (messageId) => { | ||
logs.logEvent("Jump to message requested:", messageId) | ||
} | ||
} | ||
} | ||
} | ||
|
||
LogsAndControlsPanel { | ||
id: logsAndControlsPanel | ||
|
||
SplitView.minimumWidth: 150 | ||
SplitView.preferredWidth: 250 | ||
|
||
logsView.logText: logs.logText | ||
|
||
controls: ColumnLayout { | ||
spacing: 16 | ||
} | ||
} | ||
} | ||
|
||
// category: Views |
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
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.
assigning this object results with:
It's necessary to use mechanism of stubs here. It means that store should be imported and used in it's typed form:
Similarly with
RootStore
below.