fix storystorybook pinned messages poupp page
This commit is contained in:
parent
e73bcb5b25
commit
ec394ece22
|
@ -22,81 +22,61 @@ SplitView {
|
||||||
Logs { id: logs }
|
Logs { id: logs }
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: mockMessageStore
|
id: d_msg
|
||||||
property var messages: [
|
|
||||||
{
|
readonly property var messagesModel: ListModel {
|
||||||
messageId: "msg1",
|
ListElement {
|
||||||
senderId: "user1",
|
timestamp: 1656937930123
|
||||||
senderDisplayName: "Alice",
|
senderId: "zq123456789"
|
||||||
senderOptionalName: "",
|
senderDisplayName: "simon"
|
||||||
senderIsEnsVerified: false,
|
profileImage: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0BhCExPynn1gWf9bx498P7/
|
||||||
senderIcon: "",
|
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
|
||||||
amISender: false,
|
contentType: StatusMessage.ContentType.Text
|
||||||
senderIsAdded: false,
|
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>"
|
||||||
senderTrustStatus: Constants.trustStatus.unknown,
|
isContact: true
|
||||||
messageText: "This is a pinned message",
|
isAReply: false
|
||||||
unparsedText: "This is a pinned message",
|
trustIndicator: StatusContactVerificationIcons.TrustedType.Verified
|
||||||
messageImage: "",
|
outgoingStatus: StatusMessage.OutgoingStatus.Delivered
|
||||||
messageTimestamp: 1621234567,
|
}
|
||||||
messageOutgoingStatus: "",
|
ListElement {
|
||||||
resendError: "",
|
timestamp: 1657937930135
|
||||||
messageContentType: Constants.messageContentType.messageType,
|
senderId: "zqABCDEFG"
|
||||||
pinnedMessage: true,
|
senderDisplayName: "Mark Cuban"
|
||||||
messagePinnedBy: "user2",
|
contentType: StatusMessage.ContentType.Text
|
||||||
reactionsModel: [],
|
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"
|
||||||
linkPreviewModel: null,
|
isContact: false
|
||||||
messageAttachments: "",
|
isAReply: false
|
||||||
transactionParams: null,
|
trustIndicator: StatusContactVerificationIcons.TrustedType.Untrustworthy
|
||||||
emojiReactionsModel: null,
|
outgoingStatus: StatusMessage.OutgoingStatus.Delivered
|
||||||
responseToMessageWithId: "",
|
}
|
||||||
quotedMessageText: "",
|
ListElement {
|
||||||
quotedMessageFrom: "",
|
timestamp: 1667937930159
|
||||||
quotedMessageContentType: Constants.messageContentType.messageType,
|
senderId: "zqdeadbeef"
|
||||||
quotedMessageDeleted: false,
|
senderDisplayName: "replicator.stateofus.eth"
|
||||||
album: [],
|
contentType: StatusMessage.ContentType.Text
|
||||||
albumCount: 0,
|
message: "Test reply; the original text above should have a horizontal gradient mask"
|
||||||
quotedMessageAlbumMessageImages: [],
|
isContact: true
|
||||||
quotedMessageAlbumImagesCount: 0
|
isAReply: true
|
||||||
},
|
trustIndicator: StatusContactVerificationIcons.TrustedType.None
|
||||||
{
|
outgoingStatus: StatusMessage.OutgoingStatus.Delivered
|
||||||
messageId: "msg2",
|
}
|
||||||
senderId: "user2",
|
}
|
||||||
senderDisplayName: "Bob",
|
readonly property var colorHash: ListModel {
|
||||||
senderOptionalName: "",
|
ListElement { colorId: 13; segmentLength: 5 }
|
||||||
senderIsEnsVerified: false,
|
ListElement { colorId: 31; segmentLength: 5 }
|
||||||
senderIcon: "",
|
ListElement { colorId: 10; segmentLength: 1 }
|
||||||
amISender: false,
|
}
|
||||||
senderIsAdded: false,
|
}
|
||||||
senderTrustStatus: Constants.trustStatus.unknown,
|
|
||||||
messageText: "Another pinned message",
|
QtObject {
|
||||||
unparsedText: "Another pinned message",
|
id: mockMessageStore
|
||||||
messageImage: "",
|
// redo it, use first message as pinned message from d_msg.messagesModel the one whose timestamp is 1656937930123
|
||||||
messageTimestamp: 1621234568,
|
property ListModel pinnedMessagesModel: ListModel {
|
||||||
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) {
|
function getMessageByIndexAsJson(index) {
|
||||||
if (index >= 0 && index < messages.length) {
|
if (index >= 0 && index < pinnedMessagesModel.count) {
|
||||||
return JSON.stringify(messages[index])
|
return JSON.stringify(pinnedMessagesModel.get(index))
|
||||||
}
|
}
|
||||||
return "{}"
|
return "{}"
|
||||||
}
|
}
|
||||||
|
@ -153,8 +133,45 @@ SplitView {
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Open Pinned Messages Popup"
|
text: "Open Empty Pinned Messages Popup"
|
||||||
onClicked: {
|
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.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +180,8 @@ SplitView {
|
||||||
PinnedMessagesPopup {
|
PinnedMessagesPopup {
|
||||||
id: pinnedMessagesPopup
|
id: pinnedMessagesPopup
|
||||||
store: mockRootStore
|
store: mockRootStore
|
||||||
messageStore: mockMessageStore
|
messageStore: d_msg
|
||||||
pinnedMessagesModel: mockMessageStore.messages
|
pinnedMessagesModel: mockMessageStore.pinnedMessagesModel
|
||||||
chatId: "chat1"
|
chatId: "chat1"
|
||||||
|
|
||||||
property var chatContentModule: QtObject {
|
property var chatContentModule: QtObject {
|
||||||
|
@ -173,7 +190,7 @@ SplitView {
|
||||||
property bool canPost: true
|
property bool canPost: true
|
||||||
property bool canView: true
|
property bool canView: true
|
||||||
}
|
}
|
||||||
property var pinnedMessagesModel: mockMessageStore.messages
|
property var pinnedMessagesModel: mockMessageStore.pinnedMessagesModel
|
||||||
}
|
}
|
||||||
|
|
||||||
property var usersStore: QtObject {
|
property var usersStore: QtObject {
|
||||||
|
@ -219,72 +236,6 @@ SplitView {
|
||||||
|
|
||||||
controls: ColumnLayout {
|
controls: ColumnLayout {
|
||||||
spacing: 16
|
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.isPinActionAvailable = checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: messageToPinInput
|
|
||||||
placeholderText: "Message to pin"
|
|
||||||
onTextChanged: {
|
|
||||||
pinnedMessagesPopup.messageToPin = text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue