ability to re-fetch profiles

dbus-notify
Zlatin Balevsky 2022-06-06 07:39:47 +01:00
parent ed9b4f2014
commit d730127486
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 30 additions and 11 deletions

View File

@ -24,6 +24,7 @@ class ViewProfileController {
@ControllerAction
void fetch() {
model.register()
model.fetch()
}
@ControllerAction

View File

@ -726,6 +726,7 @@ PROFILE_VIEWER_FETCH=Fetch Profile
PROFILE_VIEWER_AVATAR=User Avatar
PROFILE_VIEWER_PROFILE=Profile
PROFILE_VIEWER_BLOCK=Block
PROFILE_VIEWER_UPDATE=Update Profile
## Tooltips
@ -906,6 +907,7 @@ TOOLTIP_PROFILE_EDITOR_GENERATE=Generate an avatar from your MuWire ID
TOOLTIP_PROFILE_VIEWER_FETCH=Fetch the full profile of this user
TOOLTIP_PROFILE_VIEWER_ADD_CONTACT=Add this user as a trusted contact
TOOLTIP_PROFILE_VIEWER_BLOCK=Block this user
TOOLTIP_PROFILE_VIEWER_UPDATE=Check for updated profile
## Test string
TEST_PLURALIZABLE_STRING={count, plural, one {You have {count} item.} other {You have {count} items.}}

View File

@ -38,11 +38,18 @@ class ViewProfileModel {
profileTitle = HTMLSanitizer.sanitize(profileHeader.getTitle())
}
boolean fetchEnabled() {
status != MWProfileFetchStatus.CONNECTING && status != MWProfileFetchStatus.FETCHING
}
void register() {
if (registered)
return
registered = true
core.getEventBus().register(MWProfileFetchEvent.class, this)
}
void fetch() {
core.getEventBus().publish(new UIProfileFetchEvent(uuid: uuid, host: persona))
}

View File

@ -1,6 +1,7 @@
package com.muwire.gui.profile
import com.muwire.core.profile.MWProfile
import com.muwire.core.profile.MWProfileFetchStatus
import com.muwire.gui.HTMLSanitizer
import javax.imageio.ImageIO
@ -74,21 +75,29 @@ class ViewProfileView {
cardLayout()
panel(constraints: "fetch-profile") {
button(text: trans("PROFILE_VIEWER_FETCH"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_FETCH"),
enabled: bind {model.fetchEnabled()},
fetchAction)
}
panel(constraints: "full-profile") {
gridLayout(rows: 1, cols: 2)
panel(border: titledBorder(title: trans("PROFILE_VIEWER_AVATAR"), border: etchedBorder(),
titlePosition: TitledBorder.TOP)) {
gridLayout(rows: 1, cols: 1)
widget(imagePanel)
}
panel(border: titledBorder(title: trans("PROFILE_VIEWER_PROFILE"), border: etchedBorder(),
titlePosition: TitledBorder.TOP)) {
gridLayout(rows: 1, cols: 1)
scrollPane {
bodyArea = textArea(editable: false, lineWrap: true, wrapStyleWord: true)
borderLayout()
panel(constraints: BorderLayout.CENTER) {
gridLayout(rows: 1, cols: 2)
panel(border: titledBorder(title: trans("PROFILE_VIEWER_AVATAR"), border: etchedBorder(),
titlePosition: TitledBorder.TOP)) {
gridLayout(rows: 1, cols: 1)
widget(imagePanel)
}
panel(border: titledBorder(title: trans("PROFILE_VIEWER_PROFILE"), border: etchedBorder(),
titlePosition: TitledBorder.TOP)) {
gridLayout(rows: 1, cols: 1)
scrollPane {
bodyArea = textArea(editable: false, lineWrap: true, wrapStyleWord: true)
}
}
}
panel(constraints: BorderLayout.SOUTH) {
button(text: trans("PROFILE_VIEWER_UPDATE"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_UPDATE"),
enabled: bind { model.fetchEnabled()}, fetchAction)
}
}
}