-
Notifications
You must be signed in to change notification settings - Fork 86
WIP: enable cross category drag and drop #3676
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
Changes from all commits
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 |
---|---|---|
|
@@ -16,6 +16,19 @@ type | |
InProgress, | ||
Error | ||
|
||
proc ensureCorrectChatPositions(community: var Community, chat: Chat) = | ||
var i = 0 | ||
for c in community.chats: | ||
if (c.categoryId == chat.categoryId and c.id != chat.id): | ||
if (c.position == 0): | ||
community.chats[i].position = 1 | ||
|
||
if (c.position >= chat.position+1): | ||
community.chats[i].position = c.position + 1 | ||
|
||
i = i + 1 | ||
|
||
|
||
proc mergeChat(community: var Community, chat: Chat): bool = | ||
var i = 0 | ||
for c in community.chats: | ||
|
@@ -90,11 +103,17 @@ QtObject: | |
|
||
result.add(community) | ||
|
||
proc updateCommunityChat*(self: CommunitiesView, newChat: Chat) = | ||
proc updateCommunityChat*(self: CommunitiesView, newChat: Chat, ensureCorrectPositions = false) = | ||
var community = self.joinedCommunityList.getCommunityById(newChat.communityId) | ||
if (community.id == ""): | ||
return | ||
|
||
#if ensureCorrectPositions: | ||
# This is to visually put the updated chat in the correct (new) | ||
# position so we don't get a funny flicker effect once the position | ||
# was updated in the backend. | ||
#ensureCorrectChatPositions(community, newChat) | ||
#else: | ||
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. For the time being I've commented it out to ensure drag and drop works otherwise. |
||
let found = mergeChat(community, newChat) | ||
|
||
if (not found): | ||
|
@@ -228,6 +247,16 @@ QtObject: | |
proc addCommunityToList*(self: CommunitiesView, community: var Community) = | ||
var communities = @[community] | ||
community = self.populateChats(communities)[0] | ||
|
||
#echo "COMMUNITY CHATS: ", $community.chats | ||
|
||
for cat in community.categories: | ||
echo "Category: ", cat.name | ||
|
||
for c in community.chats: | ||
if c.categoryId == cat.id: | ||
echo "-> ", c.name, ": ", c.position | ||
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. This is just debugging output which can be ignored and will be removed before merge. Helps inspecting what chat items belong to which categories when we get an update from status-go. That's how I verified the bug reported in status-im/status-go#2376 |
||
|
||
let communityCheck = self.communityList.getCommunityById(community.id) | ||
if (communityCheck.id == ""): | ||
self.communityList.addCommunityItemToList(community) | ||
|
@@ -353,14 +382,6 @@ QtObject: | |
error "Error reorder the category", msg = e.msg | ||
result = fmt"Error reorder the category: {e.msg}" | ||
|
||
proc reorderCommunityChannel*(self: CommunitiesView, communityId: string, categoryId: string, chatId: string, position: int): string {.slot} = | ||
result = "" | ||
try: | ||
self.status.chat.reorderCommunityChannel(communityId, categoryId, chatId, position) | ||
except Exception as e: | ||
error "Error reorder the channel", msg = e.msg | ||
result = fmt"Error reorder the channel: {e.msg}" | ||
|
||
|
||
proc setObservedCommunity*(self: CommunitiesView, communityId: string) {.slot.} = | ||
if(communityId == ""): return | ||
|
@@ -510,6 +531,26 @@ QtObject: | |
chat.muted = true | ||
return chat | ||
|
||
proc reorderCommunityChannel*(self: CommunitiesView, communityId: string, categoryId: string, chatId: string, position: int): string {.slot} = | ||
|
||
var chat = self.getChannel(chatId) | ||
chat.categoryId = categoryId | ||
chat.position = position | ||
|
||
# Update chat object and persist new position in memory until | ||
# backend has been updated with new chat position. | ||
self.updateCommunityChat(chat, 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. This is part of visually updating the new order in QML, but before we the reorder signal was sent to status-go.
|
||
|
||
result = "" | ||
|
||
try: | ||
echo "REQUEST REORDER: ", position | ||
self.status.chat.reorderCommunityChannel(communityId, categoryId, chatId, position) | ||
except Exception as e: | ||
error "Error reorder the channel", msg = e.msg | ||
result = fmt"Error reorder the channel: {e.msg}" | ||
|
||
|
||
proc deleteCommunityChat*(self: CommunitiesView, communityId: string, channelId: string): string {.slot.} = | ||
try: | ||
self.status.chat.deleteCommunityChat(communityId, channelId) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ Item { | |
ScrollView { | ||
id: chatGroupsContainer | ||
anchors.top: membershipRequests.bottom | ||
anchors.topMargin: Style.current.padding | ||
anchors.topMargin: Style.current.padding - 8 | ||
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. I've added this because, with the new drag and drop capabilities, users can drag out of a category, To make that work, there's an additional 8px space at the top of the We actually need to check whether the "uncategorized" chat list is indeed empty and only then substract the height here (because only then the new drop area is active and visible) |
||
anchors.bottom: parent.bottom | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
|
||
|
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.
This is a WIP attempt to update the chat item
positions
until we get a response from status-go.This is the part I need help with.