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 @ControllerAction
void fetch() { void fetch() {
model.register() model.register()
model.fetch()
} }
@ControllerAction @ControllerAction

View File

@ -726,6 +726,7 @@ PROFILE_VIEWER_FETCH=Fetch Profile
PROFILE_VIEWER_AVATAR=User Avatar PROFILE_VIEWER_AVATAR=User Avatar
PROFILE_VIEWER_PROFILE=Profile PROFILE_VIEWER_PROFILE=Profile
PROFILE_VIEWER_BLOCK=Block PROFILE_VIEWER_BLOCK=Block
PROFILE_VIEWER_UPDATE=Update Profile
## Tooltips ## 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_FETCH=Fetch the full profile of this user
TOOLTIP_PROFILE_VIEWER_ADD_CONTACT=Add this user as a trusted contact TOOLTIP_PROFILE_VIEWER_ADD_CONTACT=Add this user as a trusted contact
TOOLTIP_PROFILE_VIEWER_BLOCK=Block this user TOOLTIP_PROFILE_VIEWER_BLOCK=Block this user
TOOLTIP_PROFILE_VIEWER_UPDATE=Check for updated profile
## Test string ## Test string
TEST_PLURALIZABLE_STRING={count, plural, one {You have {count} item.} other {You have {count} items.}} 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()) profileTitle = HTMLSanitizer.sanitize(profileHeader.getTitle())
} }
boolean fetchEnabled() {
status != MWProfileFetchStatus.CONNECTING && status != MWProfileFetchStatus.FETCHING
}
void register() { void register() {
if (registered) if (registered)
return return
registered = true registered = true
core.getEventBus().register(MWProfileFetchEvent.class, this) core.getEventBus().register(MWProfileFetchEvent.class, this)
}
void fetch() {
core.getEventBus().publish(new UIProfileFetchEvent(uuid: uuid, host: persona)) core.getEventBus().publish(new UIProfileFetchEvent(uuid: uuid, host: persona))
} }

View File

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