Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 1x 1x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x 2x | import { Component, HostBinding, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { RouterLink } from '@angular/router';
import { isEqual, uniq } from 'lodash-es';
import { autorun, IReactionDisposer, runInAction } from 'mobx';
import { MobxAngularModule } from 'mobx-angular';
import { LensComponent } from '../../component/lens/lens.component';
import { LoadingComponent } from '../../component/loading/loading.component';
import { SidebarComponent } from '../../component/sidebar/sidebar.component';
import { TabsComponent } from '../../component/tabs/tabs.component';
import { HasChanges } from '../../guard/pending-changes.guard';
import { AccountService } from '../../service/account.service';
import { AdminService } from '../../service/admin.service';
import { ExtService } from '../../service/api/ext.service';
import { BookmarkService } from '../../service/bookmark.service';
import { ModService } from '../../service/mod.service';
import { QueryStore } from '../../store/query';
import { Store } from '../../store/store';
import { getArgs, UrlFilter } from '../../util/query';
import { hasPrefix } from '../../util/tag';
@Component({
selector: 'app-tag-page',
templateUrl: './tag.component.html',
styleUrls: ['./tag.component.scss'],
imports: [
LensComponent,
MobxAngularModule,
TabsComponent,
RouterLink,
SidebarComponent,
LoadingComponent,
],
})
export class TagPage implements OnInit, OnDestroy, HasChanges {
private disposers: IReactionDisposer[] = [];
loading = true;
@ViewChild('lens')
lens?: LensComponent;
constructor(
public admin: AdminService,
public account: AccountService,
public store: Store,
public query: QueryStore,
private mod: ModService,
private exts: ExtService,
private bookmarks: BookmarkService,
) {
this.disposers.push(autorun(() => this.mod.setTitle(this.store.view.name)));
runInAction(() => {
this.store.view.clear([
!!this.admin.getPlugin('plugin/user/vote/up')
? 'plugins->plugin/user/vote:decay'
: this.store.view.tag.includes('*')
? 'published'
: 'created'
]);
this.store.view.extTemplates = this.admin.view;
});
this.disposers.push(autorun(() => {
if (!this.store.view.queryTags.length) {
runInAction(() => this.store.view.exts = []);
this.loading = false;
} else E{
this.loading = true;
this.exts.getCachedExts(this.store.view.queryTags)
.pipe(this.admin.extFallbacks)
.subscribe(exts => {
if (!isEqual(exts.map(x => x.tag + x.origin + x.modifiedString).sort(), this.store.view.exts.map(x => x.tag + x.origin + x.modifiedString).sort())) {
runInAction(() => this.store.view.exts = exts);
}
this.loading = false;
});
}
}));
this.query.clear();
}
saveChanges() {
return !this.lens || this.lens.saveChanges();
}
ngOnInit() {
this.disposers.push(autorun(() => {
Iif (hasPrefix(this.store.view.viewExt?.tag, 'kanban')) return;
Iif (hasPrefix(this.store.view.viewExt?.tag, 'chat')) return;
const filters = this.store.view.filter.length ? this.store.view.filter : this.store.view.viewExtFilter;
Iif (!this.store.view.filter.length && this.store.view.viewExtFilter?.length) {
this.bookmarks.filters = this.store.view.viewExtFilter;
}
const hideInternal = !this.admin.getPlugins(this.store.view.queryTags).length;
const args = getArgs(
this.store.view.tag,
this.store.view.sort,
uniq([...hideInternal ? ['query/!internal', 'query/!plugin/delete', 'user/!plugin/user/hide'] : ['query/!plugin/delete', 'user/!plugin/user/hide'], ...filters || []]) as UrlFilter[],
this.store.view.search,
this.store.view.pageNumber,
this.store.view.pageSize,
);
runInAction(() => this.query.setArgs(args));
}));
}
ngOnDestroy() {
this.query.close();
for (const dispose of this.disposers) dispose();
this.disposers.length = 0;
}
@HostBinding('class.no-footer-padding')
get noFooterPadding() {
return this.store.view.isTemplate('kanban');
}
}
|