-
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
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: mockMessageStore | ||
property var messages: [ | ||
{ | ||
messageId: "msg1", | ||
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. Role names used here doesn't match what's expected in MessageView {
id: messageItem
messageId: model.id
// ...
} So |
||
senderId: "user1", | ||
senderDisplayName: "Alice", | ||
senderOptionalName: "", | ||
senderIsEnsVerified: false, | ||
senderIcon: "", | ||
amISender: false, | ||
senderIsAdded: false, | ||
senderTrustStatus: Constants.trustStatus.unknown, | ||
messageText: "This is a pinned message", | ||
unparsedText: "This is a pinned message", | ||
messageImage: "", | ||
messageTimestamp: 1621234567, | ||
messageOutgoingStatus: "", | ||
resendError: "", | ||
messageContentType: Constants.messageContentType.messageType, | ||
pinnedMessage: true, | ||
messagePinnedBy: "user2", | ||
reactionsModel: [], | ||
linkPreviewModel: null, | ||
messageAttachments: "", | ||
transactionParams: null, | ||
emojiReactionsModel: null, | ||
responseToMessageWithId: "", | ||
quotedMessageText: "", | ||
quotedMessageFrom: "", | ||
quotedMessageContentType: Constants.messageContentType.messageType, | ||
quotedMessageDeleted: false, | ||
album: [], | ||
albumCount: 0, | ||
quotedMessageAlbumMessageImages: [], | ||
quotedMessageAlbumImagesCount: 0 | ||
}, | ||
{ | ||
messageId: "msg2", | ||
senderId: "user2", | ||
senderDisplayName: "Bob", | ||
senderOptionalName: "", | ||
senderIsEnsVerified: false, | ||
senderIcon: "", | ||
amISender: false, | ||
senderIsAdded: false, | ||
senderTrustStatus: Constants.trustStatus.unknown, | ||
messageText: "Another pinned message", | ||
unparsedText: "Another pinned message", | ||
messageImage: "", | ||
messageTimestamp: 1621234568, | ||
messageOutgoingStatus: "", | ||
resendError: "", | ||
messageContentType: Constants.messageContentType.messageType, | ||
pinnedMessage: true, | ||
messagePinnedBy: "user1", | ||
reactionsModel: [], | ||
linkPreviewModel: null, | ||
messageAttachments: "", | ||
transactionParams: null, | ||
emojiReactionsModel: null, | ||
responseToMessageWithId: "", | ||
quotedMessageText: "", | ||
quotedMessageFrom: "", | ||
quotedMessageContentType: Constants.messageContentType.messageType, | ||
quotedMessageDeleted: false, | ||
album: [], | ||
albumCount: 0, | ||
quotedMessageAlbumMessageImages: [], | ||
quotedMessageAlbumImagesCount: 0 | ||
} | ||
] | ||
|
||
function getMessageByIndexAsJson(index) { | ||
if (index >= 0 && index < messages.length) { | ||
return JSON.stringify(messages[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 Pinned Messages Popup" | ||
onClicked: { | ||
pinnedMessagesPopup.open() | ||
} | ||
} | ||
} | ||
|
||
PinnedMessagesPopup { | ||
id: pinnedMessagesPopup | ||
store: mockRootStore | ||
messageStore: mockMessageStore | ||
pinnedMessagesModel: mockMessageStore.messages | ||
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. What is expected here is model, so it should be like: ListModel {
id: messagesModel
Component.onCompleted: {
append(messages)
}
} and |
||
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.messages | ||
} | ||
|
||
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 | ||
|
||
Button { | ||
text: "Add Pinned Message" | ||
onClicked: { | ||
mockMessageStore.messages.push({ | ||
messageId: "msg" + (mockMessageStore.messages.length + 1), | ||
senderId: "user" + (mockMessageStore.messages.length + 1), | ||
senderDisplayName: "User " + (mockMessageStore.messages.length + 1), | ||
senderOptionalName: "", | ||
senderIsEnsVerified: false, | ||
senderIcon: "", | ||
amISender: false, | ||
senderIsAdded: false, | ||
senderTrustStatus: Constants.trustStatus.unknown, | ||
messageText: "New pinned message " + (mockMessageStore.messages.length + 1), | ||
unparsedText: "New pinned message " + (mockMessageStore.messages.length + 1), | ||
messageImage: "", | ||
messageTimestamp: Date.now() / 1000, | ||
messageOutgoingStatus: "", | ||
resendError: "", | ||
messageContentType: Constants.messageContentType.messageType, | ||
pinnedMessage: true, | ||
messagePinnedBy: "user1", | ||
reactionsModel: [], | ||
linkPreviewModel: null, | ||
messageAttachments: "", | ||
transactionParams: null, | ||
emojiReactionsModel: null, | ||
responseToMessageWithId: "", | ||
quotedMessageText: "", | ||
quotedMessageFrom: "", | ||
quotedMessageContentType: Constants.messageContentType.messageType, | ||
quotedMessageDeleted: false, | ||
album: [], | ||
albumCount: 0, | ||
quotedMessageAlbumMessageImages: [], | ||
quotedMessageAlbumImagesCount: 0 | ||
}) | ||
pinnedMessagesPopup.pinnedMessagesModel = mockMessageStore.messages | ||
} | ||
} | ||
|
||
Button { | ||
text: "Clear Pinned Messages" | ||
onClicked: { | ||
mockMessageStore.messages = [] | ||
pinnedMessagesPopup.pinnedMessagesModel = mockMessageStore.messages | ||
} | ||
} | ||
|
||
CheckBox { | ||
id: isPinActionAvailableCheckBox | ||
text: "Is Pin Action Available" | ||
checked: true | ||
onCheckedChanged: { | ||
pinnedMessagesPopup.isPinActionAvaliable = checked | ||
} | ||
} | ||
|
||
TextField { | ||
id: messageToPinInput | ||
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. not used? |
||
placeholderText: "Message to pin" | ||
onTextChanged: { | ||
pinnedMessagesPopup.messageToPin = text | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// category: Views |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,8 +25,11 @@ StatusDialog { | |||||
property string messageToUnpin | ||||||
property string chatId | ||||||
|
||||||
readonly property var contactDetails: store ? store.oneToOneChatContact : null | ||||||
readonly property bool isPinActionAvaliable: contactDetails ? contactDetails.isContact : true | ||||||
readonly property bool isPinActionAvaliable: true | ||||||
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.
Suggested change
|
||||||
|
||||||
signal pinMessageRequested(string messageId) | ||||||
signal unpinMessageRequested(string messageId) | ||||||
signal jumpToMessageRequested(string messageId) | ||||||
|
||||||
width: 800 | ||||||
height: 428 | ||||||
|
@@ -41,7 +44,7 @@ StatusDialog { | |||||
|
||||||
function jumpToMessage(messageId) { | ||||||
root.close() | ||||||
root.messageStore.messageModule.jumpToMessage(messageId) | ||||||
root.jumpToMessageRequested(messageId) | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -167,7 +170,7 @@ StatusDialog { | |||||
tooltip.text: qsTr("Unpin") | ||||||
color: hovered ? Theme.palette.primaryColor2 : Theme.palette.indirectColor1 | ||||||
onClicked: { | ||||||
root.messageStore.unpinMessage(model.id) | ||||||
root.unpinMessageRequested(model.id) | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -246,9 +249,9 @@ StatusDialog { | |||||
enabled: !!root.messageToUnpin && pinButtonGroup.checkedButton | ||||||
text: qsTr("Unpin selected message and pin new message") | ||||||
onClicked: { | ||||||
root.messageStore.unpinMessage(root.messageToUnpin) | ||||||
root.unpinMessageRequested(root.messageToUnpin) | ||||||
root.messageToUnpin = "" | ||||||
root.messageStore.pinMessage(root.messageToPin) | ||||||
root.pinMessageRequested(root.messageToPin) | ||||||
root.messageToPin = "" | ||||||
root.close() | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -264,7 +264,8 @@ QtObject { | |||||
messageStore: messageStore, | ||||||
pinnedMessagesModel: pinnedMessagesModel, | ||||||
messageToPin: messageToPin, | ||||||
chatId: chatId | ||||||
chatId: chatId, | ||||||
isPinActionAvaliable: store && store.oneToOneChatContact ? store.oneToOneChatContact.isContact : true | ||||||
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.
Suggested change
|
||||||
}) | ||||||
} | ||||||
|
||||||
|
@@ -642,6 +643,9 @@ QtObject { | |||||
id: pinnedMessagesPopup | ||||||
PinnedMessagesPopup { | ||||||
onClosed: destroy() | ||||||
onPinMessageRequested: messageStore.pinMessage(messageId) | ||||||
onUnpinMessageRequested: messageStore.unpinMessage(messageId) | ||||||
onJumpToMessageRequested: messageStore.messageModule.jumpToMessage(messageId) | ||||||
} | ||||||
}, | ||||||
|
||||||
|
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.