make preview useable without client list, to reuse in create link view
This commit is contained in:
@@ -15,12 +15,12 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import {TemplateView} from "../utils/TemplateView.js";
|
||||
import {ClientListView} from "../client/ClientListView.js";
|
||||
import {ClientView} from "../client/ClientView.js";
|
||||
import {ClientListView} from "../open/ClientListView.js";
|
||||
import {ClientView} from "../open/ClientView.js";
|
||||
|
||||
export class PreviewView extends TemplateView {
|
||||
render(t, vm) {
|
||||
return t.div({className: "PreviewView card"}, [
|
||||
return t.div({className: "PreviewView"}, [
|
||||
t.h1({className: {hidden: vm => !vm.loading}}, "Loading preview…"),
|
||||
t.div({className: {hidden: vm => vm.loading}}, [
|
||||
t.div({className: "preview"}, [
|
||||
@@ -30,12 +30,6 @@ export class PreviewView extends TemplateView {
|
||||
t.p({className: {memberCount: true, hidden: vm => !vm.memberCount}}, [vm => vm.memberCount, " members"]),
|
||||
t.p({className: {topic: true, hidden: vm => !vm.topic}}, [vm => vm.topic]),
|
||||
]),
|
||||
t.p({className: {hidden: vm => vm.clientsViewModel}}, t.button({
|
||||
className: "primary fullwidth",
|
||||
onClick: () => vm.showClients()
|
||||
}, vm => vm.showClientsLabel)),
|
||||
t.mapView(vm => vm.clientsViewModel, childVM => childVM ? new ClientListView(childVM) : null),
|
||||
t.p(["Preview provided by ", vm => vm.previewDomain]),
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -14,21 +14,18 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {LinkKind, IdentifierKind, getLabelForLinkKind} from "../Link.js";
|
||||
import {LinkKind, IdentifierKind} from "../Link.js";
|
||||
import {ViewModel} from "../utils/ViewModel.js";
|
||||
import {resolveServer} from "./HomeServer.js";
|
||||
import {ClientListViewModel} from "../client/ClientListViewModel.js";
|
||||
import {ClientViewModel} from "../client/ClientViewModel.js";
|
||||
import {ClientListViewModel} from "../open/ClientListViewModel.js";
|
||||
import {ClientViewModel} from "../open/ClientViewModel.js";
|
||||
|
||||
export class PreviewViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
const { link, consentedServers, clients } = options;
|
||||
const { link, consentedServers } = options;
|
||||
this._link = link;
|
||||
this._consentedServers = consentedServers;
|
||||
this._clients = clients;
|
||||
this._preferredClient = this.preferences.clientId ? clients.find(c => c.id === this.preferences.clientId) : null;
|
||||
|
||||
this.loading = false;
|
||||
this.name = null;
|
||||
this.avatarUrl = null;
|
||||
@@ -36,13 +33,6 @@ export class PreviewViewModel extends ViewModel {
|
||||
this.memberCount = null;
|
||||
this.topic = null;
|
||||
this.previewDomain = null;
|
||||
this.clientsViewModel = null;
|
||||
this.acceptInstructions = null;
|
||||
this.clientsViewModel = this._preferredClient ? new ClientListViewModel(this.childOptions({
|
||||
clients: this._clients,
|
||||
client: this._preferredClient,
|
||||
link: this._link,
|
||||
})) : null;
|
||||
}
|
||||
|
||||
async load() {
|
||||
@@ -97,15 +87,4 @@ export class PreviewViewModel extends ViewModel {
|
||||
this.topic = publicRoom?.topic;
|
||||
this.identifier = publicRoom?.canonical_alias || link.identifier;
|
||||
}
|
||||
|
||||
get showClientsLabel() {
|
||||
return getLabelForLinkKind(this._link.kind);
|
||||
}
|
||||
|
||||
showClients() {
|
||||
if (!this.clientsViewModel) {
|
||||
this.clientsViewModel = new ClientListViewModel(this.childOptions({clients: this._clients, link: this._link}));
|
||||
this.emitChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user