enhance bookmarks support, fix #583
This commit is contained in:
parent
ba08c0d0b2
commit
7013d9174c
@ -60,8 +60,8 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
private readonly mastodonService: MastodonWrapperService,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly userNotificationService: UserNotificationService) {
|
||||
super();
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
@ -71,13 +71,9 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
}
|
||||
|
||||
private checkIfBookmarksAreAvailable() {
|
||||
this.toolsService.getInstanceInfo(this.account.info)
|
||||
.then((instance: InstanceInfo) => {
|
||||
if (instance.major == 3 && instance.minor >= 1 || instance.major > 3) {
|
||||
this.isBookmarksAvailable = true;
|
||||
} else {
|
||||
this.isBookmarksAvailable = false;
|
||||
}
|
||||
this.toolsService.isBookmarksAreAvailable(this.account.info)
|
||||
.then((isAvailable: boolean) => {
|
||||
this.isBookmarksAvailable = isAvailable;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isBookmarksAvailable = false;
|
||||
@ -128,15 +124,15 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewChild('bookmarks') bookmarksComp:BookmarksComponent;
|
||||
@ViewChild('notifications') notificationsComp:NotificationsComponent;
|
||||
@ViewChild('mentions') mentionsComp:MentionsComponent;
|
||||
@ViewChild('dm') dmComp:DirectMessagesComponent;
|
||||
@ViewChild('favorites') favoritesComp:FavoritesComponent;
|
||||
@ViewChild('bookmarks') bookmarksComp: BookmarksComponent;
|
||||
@ViewChild('notifications') notificationsComp: NotificationsComponent;
|
||||
@ViewChild('mentions') mentionsComp: MentionsComponent;
|
||||
@ViewChild('dm') dmComp: DirectMessagesComponent;
|
||||
@ViewChild('favorites') favoritesComp: FavoritesComponent;
|
||||
|
||||
loadSubPanel(subpanel: 'account' | 'notifications' | 'mentions' | 'dm' | 'favorites' | 'bookmarks'): boolean {
|
||||
if(this.subPanel === subpanel){
|
||||
switch(subpanel){
|
||||
if (this.subPanel === subpanel) {
|
||||
switch (subpanel) {
|
||||
case 'bookmarks':
|
||||
this.bookmarksComp.applyGoToTop();
|
||||
break;
|
||||
|
@ -342,13 +342,9 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private checkIfBookmarksAreAvailable(account: AccountInfo) {
|
||||
this.toolsService.getInstanceInfo(account)
|
||||
.then((instance: InstanceInfo) => {
|
||||
if (instance.major == 3 && instance.minor >= 1 || instance.major > 3) {
|
||||
this.isBookmarksAvailable = true;
|
||||
} else {
|
||||
this.isBookmarksAvailable = false;
|
||||
}
|
||||
this.toolsService.isBookmarksAreAvailable(account)
|
||||
.then((isAvailable: boolean) => {
|
||||
this.isBookmarksAvailable = isAvailable;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isBookmarksAvailable = false;
|
||||
|
@ -77,21 +77,47 @@ export class ToolsService {
|
||||
return Promise.resolve(this.instanceInfos[acc.instance]);
|
||||
} else {
|
||||
return this.mastodonService.getInstance(acc.instance)
|
||||
.then(instance => {
|
||||
let type = InstanceType.Mastodon;
|
||||
if (instance.version.toLowerCase().includes('pleroma')) {
|
||||
type = InstanceType.Pleroma;
|
||||
} else if (instance.version.toLowerCase().includes('+glitch')) {
|
||||
type = InstanceType.GlitchSoc;
|
||||
} else if (instance.version.toLowerCase().includes('+florence')) {
|
||||
type = InstanceType.Florence;
|
||||
} else if (instance.version.toLowerCase().includes('pixelfed')) {
|
||||
type = InstanceType.Pixelfed;
|
||||
}
|
||||
|
||||
.then(instance => {
|
||||
const splittedVersion = instance.version.split('.');
|
||||
const major = +splittedVersion[0];
|
||||
const minor = +splittedVersion[1];
|
||||
let major = +splittedVersion[0];
|
||||
let minor = +splittedVersion[1];
|
||||
|
||||
let altMajor = 0;
|
||||
let altMinor = 0;
|
||||
|
||||
let type = InstanceType.Mastodon;
|
||||
|
||||
const version = instance.version.toLowerCase();
|
||||
|
||||
if (version.includes('pleroma')) {
|
||||
type = InstanceType.Pleroma;
|
||||
|
||||
const pleromaVersion = version.split('pleroma ')[1].split('.');
|
||||
altMajor = +pleromaVersion[0];
|
||||
altMinor = +pleromaVersion[1];
|
||||
|
||||
} else if (version.includes('+glitch')) {
|
||||
type = InstanceType.GlitchSoc;
|
||||
} else if (version.includes('+florence')) {
|
||||
type = InstanceType.Florence;
|
||||
} else if (version.includes('pixelfed')) {
|
||||
type = InstanceType.Pixelfed;
|
||||
} else if (version.includes('takahe')) {
|
||||
type = InstanceType.Takahe;
|
||||
major = 1; //FIXME: when a clearer set of feature are available
|
||||
minor = 0; //FIXME: when a clearer set of feature are available
|
||||
|
||||
const takaheVersion = version.split('takahe/')[1].split('.');
|
||||
altMajor = +takaheVersion[0];
|
||||
altMinor = +takaheVersion[1];
|
||||
|
||||
} else if (version.includes('akkoma')) {
|
||||
type = InstanceType.Akkoma;
|
||||
|
||||
const akkomaVersion = version.split('akkoma ')[1].split('.');
|
||||
altMajor = +akkomaVersion[0];
|
||||
altMinor = +akkomaVersion[1];
|
||||
}
|
||||
|
||||
let streamingApi = "";
|
||||
|
||||
@ -108,7 +134,7 @@ export class ToolsService {
|
||||
streamingApi = instanceV1.urls.streaming_api;
|
||||
}
|
||||
|
||||
let instanceInfo = new InstanceInfo(type, major, minor, streamingApi);
|
||||
let instanceInfo = new InstanceInfo(type, major, minor, streamingApi, altMajor, altMinor);
|
||||
this.instanceInfos[acc.instance] = instanceInfo;
|
||||
|
||||
return instanceInfo;
|
||||
@ -116,6 +142,25 @@ export class ToolsService {
|
||||
}
|
||||
}
|
||||
|
||||
isBookmarksAreAvailable(account: AccountInfo): Promise<boolean> {
|
||||
return this.getInstanceInfo(account)
|
||||
.then((instance: InstanceInfo) => {
|
||||
if (instance.major == 3 && instance.minor >= 1
|
||||
|| instance.major > 3
|
||||
|| instance.type === InstanceType.Pleroma && instance.altMajor >= 2 && instance.altMinor >= 5
|
||||
|| instance.type === InstanceType.Akkoma && instance.altMajor >= 3 && instance.altMinor >= 9
|
||||
|| instance.type === InstanceType.Takahe && instance.altMajor >= 0 && instance.altMinor >= 9) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
getAvatar(acc: AccountInfo): Promise<string> {
|
||||
if (this.accountAvatar[acc.id]) {
|
||||
return Promise.resolve(this.accountAvatar[acc.id]);
|
||||
@ -247,16 +292,20 @@ export class InstanceInfo {
|
||||
public readonly type: InstanceType,
|
||||
public readonly major: number,
|
||||
public readonly minor: number,
|
||||
public readonly streamingApi: string) {
|
||||
public readonly streamingApi: string,
|
||||
public readonly altMajor: number,
|
||||
public readonly altMinor: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export enum InstanceType {
|
||||
Mastodon = 1,
|
||||
Pleroma = 2,
|
||||
GlitchSoc = 3,
|
||||
Pleroma = 2, // "2.7.2 (compatible; Pleroma 2.5.1)"
|
||||
GlitchSoc = 3, // "4.1.5+glitch_0801_3b49b5a"
|
||||
Florence = 4,
|
||||
Pixelfed = 5
|
||||
Pixelfed = 5,
|
||||
Takahe = 6, // "takahe/0.9.0"
|
||||
Akkoma = 7, // "2.7.2 (compatible; Akkoma 3.9.2-develop)"
|
||||
}
|
||||
|
||||
export class StatusWithCwPolicyResult {
|
||||
|
Loading…
x
Reference in New Issue
Block a user