integration of twitter bridge in search workflow
This commit is contained in:
parent
7653398642
commit
d82da3d180
@ -24,6 +24,7 @@ import { PollEditorComponent } from './poll-editor/poll-editor.component';
|
||||
import { StatusSchedulerComponent } from './status-scheduler/status-scheduler.component';
|
||||
import { ScheduledStatusService } from '../../services/scheduled-status.service';
|
||||
import { StatusesStateService } from '../../services/statuses-state.service';
|
||||
import { SettingsService } from '../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-status',
|
||||
@ -186,6 +187,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||
private selectedAccount: AccountInfo;
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private statusStateService: StatusesStateService,
|
||||
private readonly scheduledStatusService: ScheduledStatusService,
|
||||
private readonly contextMenuService: ContextMenuService,
|
||||
@ -370,7 +372,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||
if (accounts && accounts.length > 0) {
|
||||
this.selectedAccount = accounts.filter(x => x.isSelected)[0];
|
||||
|
||||
const settings = this.toolsService.getAccountSettings(this.selectedAccount);
|
||||
const settings = this.settingsService.getAccountSettings(this.selectedAccount);
|
||||
if (settings.customStatusCharLengthEnabled) {
|
||||
this.maxCharLength = settings.customStatusCharLength;
|
||||
this.countStatusChar(this.status);
|
||||
|
@ -16,6 +16,7 @@ import { MentionsComponent } from './mentions/mentions.component';
|
||||
import { DirectMessagesComponent } from './direct-messages/direct-messages.component';
|
||||
import { FavoritesComponent } from './favorites/favorites.component';
|
||||
import { BrowseBase } from '../../common/browse-base';
|
||||
import { SettingsService } from '../../../services/settings.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -54,6 +55,7 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
private _account: AccountWrapper;
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly mastodonService: MastodonWrapperService,
|
||||
private readonly notificationService: NotificationService,
|
||||
@ -100,8 +102,8 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
this.userNotificationServiceSub = this.userNotificationService.userNotifications.subscribe((userNotifications: UserNotification[]) => {
|
||||
const userNotification = userNotifications.find(x => x.account.id === this.account.info.id);
|
||||
if (userNotification) {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let accSettings = this.toolsService.getAccountSettings(this.account.info);
|
||||
let settings = this.settingsService.getSettings();
|
||||
let accSettings = this.settingsService.getAccountSettings(this.account.info);
|
||||
|
||||
if (!settings.disableAvatarNotifications && !accSettings.disableAvatarNotifications) {
|
||||
this.hasNotifications = userNotification.hasNewNotifications;
|
||||
@ -113,8 +115,8 @@ export class ManageAccountComponent extends BrowseBase {
|
||||
let current = this.userNotificationService.userNotifications.value;
|
||||
const userNotification = current.find(x => x.account.id === this.account.info.id);
|
||||
if (userNotification) {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let accSettings = this.toolsService.getAccountSettings(this.account.info);
|
||||
let settings = this.settingsService.getSettings();
|
||||
let accSettings = this.settingsService.getAccountSettings(this.account.info);
|
||||
|
||||
if (!settings.disableAutofocus && !settings.disableAvatarNotifications && !accSettings.disableAvatarNotifications) {
|
||||
if (userNotification.hasNewNotifications) {
|
||||
|
@ -6,7 +6,7 @@ import { MastodonWrapperService } from '../../../../../services/mastodon-wrapper
|
||||
import { AccountWrapper } from '../../../../../models/account.models';
|
||||
import { NotificationService } from '../../../../../services/notification.service';
|
||||
import { Account, Relationship, Instance } from "../../../../../services/models/mastodon.interfaces";
|
||||
import { ToolsService } from '../../../../../services/tools.service';
|
||||
import { SettingsService } from '../../../../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-editor',
|
||||
@ -25,7 +25,7 @@ export class ListEditorComponent implements OnInit {
|
||||
searchOpen: boolean;
|
||||
|
||||
constructor(
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly mastodonService: MastodonWrapperService) { }
|
||||
|
||||
@ -70,7 +70,7 @@ export class ListEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
addEvent(accountWrapper: AccountListWrapper) {
|
||||
const settings = this.toolsService.getSettings();
|
||||
const settings = this.settingsService.getSettings();
|
||||
|
||||
accountWrapper.isLoading = true;
|
||||
this.mastodonService.getInstance(this.account.info.instance)
|
||||
|
@ -10,8 +10,8 @@ import { AccountWrapper } from '../../../../models/account.models';
|
||||
import { RemoveAccount } from '../../../../states/accounts.state';
|
||||
import { NavigationService } from '../../../../services/navigation.service';
|
||||
import { MastodonWrapperService } from '../../../../services/mastodon-wrapper.service';
|
||||
import { ToolsService } from '../../../../services/tools.service';
|
||||
import { AccountSettings } from '../../../../states/settings.state';
|
||||
import { SettingsService } from '../../../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-my-account',
|
||||
@ -49,8 +49,8 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||
private streamChangedSub: Subscription;
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly store: Store,
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly navigationService: NavigationService,
|
||||
private readonly mastodonService: MastodonWrapperService,
|
||||
private readonly notificationService: NotificationService) { }
|
||||
@ -68,7 +68,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private loadAccountSettings(){
|
||||
this.accountSettings = this.toolsService.getAccountSettings(this.account.info);
|
||||
this.accountSettings = this.settingsService.getAccountSettings(this.account.info);
|
||||
|
||||
this.customStatusLengthEnabled = this.accountSettings.customStatusCharLengthEnabled;
|
||||
this.customStatusLength = this.accountSettings.customStatusCharLength;
|
||||
@ -77,13 +77,13 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||
|
||||
onCustomLengthEnabledChanged(): boolean {
|
||||
this.accountSettings.customStatusCharLengthEnabled = this.customStatusLengthEnabled;
|
||||
this.toolsService.saveAccountSettings(this.accountSettings);
|
||||
this.settingsService.saveAccountSettings(this.accountSettings);
|
||||
return false;
|
||||
}
|
||||
|
||||
customStatusLengthChanged(event): boolean{
|
||||
this.accountSettings.customStatusCharLength = this.customStatusLength;
|
||||
this.toolsService.saveAccountSettings(this.accountSettings);
|
||||
this.settingsService.saveAccountSettings(this.accountSettings);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,9 +203,9 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onDisableAvatarNotificationChanged() {
|
||||
let settings = this.toolsService.getAccountSettings(this.account.info);
|
||||
let settings = this.settingsService.getAccountSettings(this.account.info);
|
||||
settings.disableAvatarNotifications = this.avatarNotificationDisabled;
|
||||
this.toolsService.saveAccountSettings(settings);
|
||||
this.settingsService.saveAccountSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import { ServiceWorkerService } from '../../../services/service-worker.service';
|
||||
import { ContentWarningPolicy, ContentWarningPolicyEnum, TimeLineModeEnum, TimeLineHeaderEnum } from '../../../states/settings.state';
|
||||
import { NotificationService } from '../../../services/notification.service';
|
||||
import { NavigationService } from '../../../services/navigation.service';
|
||||
import { SettingsService } from '../../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@ -76,6 +77,7 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly navigationService: NavigationService,
|
||||
private formBuilder: FormBuilder,
|
||||
private serviceWorkersService: ServiceWorkerService,
|
||||
@ -86,7 +88,7 @@ export class SettingsComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.version = environment.VERSION;
|
||||
|
||||
const settings = this.toolsService.getSettings();
|
||||
const settings = this.settingsService.getSettings();
|
||||
|
||||
this.notificationSounds = this.userNotificationsService.getAllNotificationSounds();
|
||||
this.notificationSoundId = settings.notificationSoundFileId;
|
||||
@ -133,27 +135,27 @@ export class SettingsComponent implements OnInit {
|
||||
this.columnShortcutEnabled = id;
|
||||
this.notifyRestartNeeded();
|
||||
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.columnSwitchingWinAlt = id === ColumnShortcut.Win;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onTimeLineHeaderChange(id: TimeLineHeaderEnum){
|
||||
this.timeLineHeader = id;
|
||||
this.notifyRestartNeeded();
|
||||
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.timelineHeader = id;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onTimeLineModeChange(id: TimeLineModeEnum){
|
||||
this.timeLineMode = id;
|
||||
this.notifyRestartNeeded();
|
||||
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.timelineMode = id;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onCwPolicyChange(id: ContentWarningPolicyEnum) {
|
||||
@ -165,7 +167,7 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
private setCwPolicy(id: ContentWarningPolicyEnum = null, addCw: string = null, removeCw: string = null, hide: string = null){
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
let cwPolicySettings = new ContentWarningPolicy();
|
||||
|
||||
if(id !== null){
|
||||
@ -192,7 +194,7 @@ export class SettingsComponent implements OnInit {
|
||||
cwPolicySettings.hideCompletlyContent = settings.contentWarningPolicy.hideCompletlyContent;
|
||||
}
|
||||
|
||||
this.toolsService.saveContentWarningPolicy(cwPolicySettings);
|
||||
this.settingsService.saveContentWarningPolicy(cwPolicySettings);
|
||||
}
|
||||
|
||||
private splitCwValues(data: string): string[]{
|
||||
@ -200,9 +202,9 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
private setBridgeInstance(instance: string){
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.twitterBridgeInstance = instance;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
// reload(): boolean {
|
||||
@ -212,9 +214,9 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
onChange(soundId: string) {
|
||||
this.notificationSoundId = soundId;
|
||||
let settings = this.toolsService.getSettings()
|
||||
let settings = this.settingsService.getSettings()
|
||||
settings.notificationSoundFileId = soundId;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
playNotificationSound(): boolean {
|
||||
@ -230,41 +232,41 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
onDisableAutofocusChanged() {
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.disableAutofocus = this.disableAutofocusEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onDisableRemoteStatusFetchingChanged() {
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.disableRemoteStatusFetching = this.disableRemoteStatusFetchingEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onDisableAvatarNotificationsChanged() {
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.disableAvatarNotifications = this.disableAvatarNotificationsEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onDisableSoundsEnabledChanged() {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.disableSounds = this.disableSoundsEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onAutoFollowOnListChanged(){
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.autoFollowOnListEnabled = this.autoFollowOnListEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onTwitterBridgeEnabledChanged(){
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.twitterBridgeEnabled = this.twitterBridgeEnabled;
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
isCleanningAll: boolean = false;
|
||||
|
@ -11,6 +11,7 @@ import { NavigationService, LeftPanelType } from "../../services/navigation.serv
|
||||
import { UserNotificationService, UserNotification } from '../../services/user-notification.service';
|
||||
import { ToolsService } from '../../services/tools.service';
|
||||
import { ScheduledStatusService, ScheduledStatusNotification } from '../../services/scheduled-status.service';
|
||||
import { SettingsService } from '../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: "app-left-side-bar",
|
||||
@ -34,6 +35,7 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
|
||||
private notificationSub: Subscription;
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly hotkeysService: HotkeysService,
|
||||
private readonly scheduledStatusService: ScheduledStatusService,
|
||||
private readonly toolsService: ToolsService,
|
||||
@ -133,7 +135,7 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
|
||||
this.notificationSub = this.userNotificationServiceService.userNotifications.subscribe((notifications: UserNotification[]) => {
|
||||
const settings = this.toolsService.getSettings();
|
||||
const settings = this.settingsService.getSettings();
|
||||
notifications.forEach((notification: UserNotification) => {
|
||||
const acc = this.accounts.find(x => x.info.id === notification.account.id);
|
||||
|
||||
|
@ -13,6 +13,7 @@ import { ToolsService } from '../../../services/tools.service';
|
||||
import { StatusWrapper } from '../../../models/common.model';
|
||||
import { TimeLineModeEnum } from '../../../states/settings.state';
|
||||
import { TimelineBase } from '../../common/timeline-base';
|
||||
import { SettingsService } from '../../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-stream-statuses',
|
||||
@ -43,6 +44,7 @@ export class StreamStatusesComponent extends TimelineBase {
|
||||
private streams$: Observable<StreamElement[]>;
|
||||
|
||||
constructor(
|
||||
protected readonly settingsService: SettingsService,
|
||||
protected readonly store: Store,
|
||||
protected readonly toolsService: ToolsService,
|
||||
protected readonly notificationService: NotificationService,
|
||||
@ -54,7 +56,7 @@ export class StreamStatusesComponent extends TimelineBase {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
this.timelineLoadingMode = settings.timelineMode;
|
||||
|
||||
this.goToTopSubscription = this.goToTop.subscribe(() => {
|
||||
|
@ -8,6 +8,7 @@ import { StreamStatusesComponent } from './stream-statuses/stream-statuses.compo
|
||||
import { StreamNotificationsComponent } from './stream-notifications/stream-notifications.component';
|
||||
import { TimeLineHeaderEnum } from '../../states/settings.state';
|
||||
import { AccountInfo } from '../../states/accounts.state';
|
||||
import { SettingsService } from '../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: "app-stream",
|
||||
@ -72,10 +73,12 @@ export class StreamComponent implements OnInit {
|
||||
return this._streamElement;
|
||||
}
|
||||
|
||||
constructor(private toolsService: ToolsService) { }
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly toolsService: ToolsService) { }
|
||||
|
||||
ngOnInit() {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
this.timelineHeader = settings.timelineHeader;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import scrollIntoView from 'scroll-into-view-if-needed';
|
||||
import { UserNotificationService, UserNotification } from '../../../services/user-notification.service';
|
||||
import { TimeLineModeEnum } from '../../../states/settings.state';
|
||||
import { BrowseBase } from '../../common/browse-base';
|
||||
import { SettingsService } from '../../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-thread',
|
||||
@ -54,6 +55,7 @@ export class ThreadComponent extends BrowseBase {
|
||||
private responseSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly httpClient: HttpClient,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly userNotificationService: UserNotificationService,
|
||||
@ -63,7 +65,7 @@ export class ThreadComponent extends BrowseBase {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
this.remoteStatusFetchingDisabled = settings.disableRemoteStatusFetching;
|
||||
|
||||
if (this.refreshEventEmitter) {
|
||||
|
@ -5,7 +5,7 @@ import { HotkeysService, Hotkey } from 'angular2-hotkeys';
|
||||
|
||||
import { StreamElement, StreamTypeEnum } from '../../states/streams.state';
|
||||
import { NavigationService } from '../../services/navigation.service';
|
||||
import { ToolsService } from '../../services/tools.service';
|
||||
import { SettingsService } from '../../services/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-streams-selection-footer',
|
||||
@ -17,14 +17,14 @@ export class StreamsSelectionFooterComponent implements OnInit {
|
||||
private streams$: Observable<StreamElement[]>;
|
||||
|
||||
constructor(
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly hotkeysService: HotkeysService,
|
||||
private readonly navigationService: NavigationService,
|
||||
private readonly store: Store) {
|
||||
|
||||
this.streams$ = this.store.select(state => state.streamsstatemodel.streams);
|
||||
|
||||
const settings = this.toolsService.getSettings();
|
||||
const settings = this.settingsService.getSettings();
|
||||
if(!settings.columnSwitchingWinAlt) {
|
||||
this.hotkeysService.add(new Hotkey('ctrl+right', (event: KeyboardEvent): boolean => {
|
||||
this.nextColumnSelected();
|
||||
|
@ -7,6 +7,7 @@ import { StreamTypeEnum, StreamElement } from '../states/streams.state';
|
||||
import { FavoriteResult, VisibilityEnum, PollParameters, MastodonService, BookmarkResult, FollowingResult } from './mastodon.service';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AppInfo, RegisteredAppsStateModel } from '../states/registered-apps.state';
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -15,6 +16,7 @@ export class MastodonWrapperService {
|
||||
private refreshingToken: { [id: string]: Promise<AccountInfo> } = {};
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly store: Store,
|
||||
private readonly authService: AuthService,
|
||||
private readonly mastodonService: MastodonService) { }
|
||||
@ -130,12 +132,35 @@ export class MastodonWrapperService {
|
||||
}
|
||||
|
||||
search(account: AccountInfo, query: string, version: 'v1' | 'v2', resolve: boolean = false): Promise<Results> {
|
||||
if(query.includes('twitter.com')){
|
||||
query = this.processTwitterQuery(query);
|
||||
}
|
||||
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.search(refreshedAccount, query, version, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
private processTwitterQuery(query: string): string {
|
||||
const settings = this.settingsService.getSettings();
|
||||
if(!settings.twitterBridgeInstance) return query;
|
||||
|
||||
let name;
|
||||
if(query.includes('twitter.com/')){
|
||||
console.log(query.replace('https://', '').replace('http://', '').split('/'));
|
||||
name = query.replace('https://', '').replace('http://', '').split('/')[1];
|
||||
}
|
||||
if(query.includes('@twitter.com')){
|
||||
console.log(query.split('@'));
|
||||
name = query.split('@')[0];
|
||||
if(name === '' || name == null){
|
||||
name = query.split('@')[1];
|
||||
}
|
||||
}
|
||||
return `@${name}@${settings.twitterBridgeInstance}`;
|
||||
}
|
||||
|
||||
getAccountStatuses(account: AccountInfo, targetAccountId: number, onlyMedia: boolean, onlyPinned: boolean, excludeReplies: boolean, maxId: string, sinceId: string, limit: number = 20): Promise<Status[]> {
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
@ -169,6 +194,10 @@ export class MastodonWrapperService {
|
||||
}
|
||||
|
||||
searchAccount(account: AccountInfo, query: string, limit: number = 40, following: boolean = false, resolve = true): Promise<Account[]> {
|
||||
if(query.includes('twitter.com')){
|
||||
query = this.processTwitterQuery(query);
|
||||
}
|
||||
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.searchAccount(refreshedAccount, query, limit, following, resolve);
|
||||
|
71
src/app/services/settings.service.ts
Normal file
71
src/app/services/settings.service.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Store } from '@ngxs/store';
|
||||
|
||||
import { AccountInfo } from '../states/accounts.state';
|
||||
import { MastodonWrapperService } from './mastodon-wrapper.service';
|
||||
import { Account, Results, Status, Emoji } from "./models/mastodon.interfaces";
|
||||
import { StatusWrapper } from '../models/common.model';
|
||||
import { AccountSettings, SaveAccountSettings, GlobalSettings, SaveSettings, ContentWarningPolicy, SaveContentWarningPolicy, ContentWarningPolicyEnum, TimeLineModeEnum, TimeLineHeaderEnum } from '../states/settings.state';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SettingsService {
|
||||
constructor(
|
||||
private readonly store: Store) { }
|
||||
|
||||
getSettings(): GlobalSettings {
|
||||
let settings = <GlobalSettings>this.store.snapshot().globalsettings.settings;
|
||||
|
||||
if (!settings.contentWarningPolicy) {
|
||||
var newCwPolicy = new ContentWarningPolicy();
|
||||
this.saveContentWarningPolicy(newCwPolicy);
|
||||
return <GlobalSettings>this.store.snapshot().globalsettings.settings;
|
||||
}
|
||||
|
||||
if(!settings.timelineMode){
|
||||
settings.timelineMode = TimeLineModeEnum.OnTop;
|
||||
this.saveSettings(settings);
|
||||
}
|
||||
|
||||
if(!settings.timelineHeader){
|
||||
settings.timelineHeader = TimeLineHeaderEnum.Title_DomainName;
|
||||
this.saveSettings(settings);
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
saveSettings(settings: GlobalSettings) {
|
||||
this.store.dispatch([
|
||||
new SaveSettings(settings)
|
||||
]);
|
||||
}
|
||||
|
||||
saveContentWarningPolicy(cwSettings: ContentWarningPolicy) {
|
||||
this.store.dispatch([
|
||||
new SaveContentWarningPolicy(cwSettings)
|
||||
]);
|
||||
}
|
||||
|
||||
getAccountSettings(account: AccountInfo): AccountSettings {
|
||||
let accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
|
||||
let accountSettings = accountsSettings.find(x => x.accountId === account.id);
|
||||
if (!accountSettings) {
|
||||
accountSettings = new AccountSettings();
|
||||
accountSettings.accountId = account.id;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
if (!accountSettings.customStatusCharLength) {
|
||||
accountSettings.customStatusCharLength = 500;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
return accountSettings;
|
||||
}
|
||||
|
||||
saveAccountSettings(accountSettings: AccountSettings) {
|
||||
this.store.dispatch([
|
||||
new SaveAccountSettings(accountSettings)
|
||||
]);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import { MastodonWrapperService } from './mastodon-wrapper.service';
|
||||
import { Account, Results, Status, Emoji } from "./models/mastodon.interfaces";
|
||||
import { StatusWrapper } from '../models/common.model';
|
||||
import { AccountSettings, SaveAccountSettings, GlobalSettings, SaveSettings, ContentWarningPolicy, SaveContentWarningPolicy, ContentWarningPolicyEnum, TimeLineModeEnum, TimeLineHeaderEnum } from '../states/settings.state';
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -15,6 +16,7 @@ export class ToolsService {
|
||||
private instanceInfos: { [id: string]: InstanceInfo } = {};
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly mastodonService: MastodonWrapperService,
|
||||
private readonly store: Store) { }
|
||||
|
||||
@ -26,7 +28,7 @@ export class ToolsService {
|
||||
let applyCw = false;
|
||||
let hideStatus = false;
|
||||
|
||||
let cwPolicy = this.getSettings().contentWarningPolicy;
|
||||
let cwPolicy = this.settingsService.getSettings().contentWarningPolicy;
|
||||
|
||||
let splittedContent = [];
|
||||
if ((cwPolicy.policy === ContentWarningPolicyEnum.HideAll && cwPolicy.addCwOnContent.length > 0)
|
||||
@ -129,61 +131,6 @@ export class ToolsService {
|
||||
return regAccounts.find(x => x.id === accountId);
|
||||
}
|
||||
|
||||
getAccountSettings(account: AccountInfo): AccountSettings {
|
||||
let accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
|
||||
let accountSettings = accountsSettings.find(x => x.accountId === account.id);
|
||||
if (!accountSettings) {
|
||||
accountSettings = new AccountSettings();
|
||||
accountSettings.accountId = account.id;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
if (!accountSettings.customStatusCharLength) {
|
||||
accountSettings.customStatusCharLength = 500;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
return accountSettings;
|
||||
}
|
||||
|
||||
saveAccountSettings(accountSettings: AccountSettings) {
|
||||
this.store.dispatch([
|
||||
new SaveAccountSettings(accountSettings)
|
||||
]);
|
||||
}
|
||||
|
||||
getSettings(): GlobalSettings {
|
||||
let settings = <GlobalSettings>this.store.snapshot().globalsettings.settings;
|
||||
|
||||
if (!settings.contentWarningPolicy) {
|
||||
var newCwPolicy = new ContentWarningPolicy();
|
||||
this.saveContentWarningPolicy(newCwPolicy);
|
||||
return <GlobalSettings>this.store.snapshot().globalsettings.settings;
|
||||
}
|
||||
|
||||
if(!settings.timelineMode){
|
||||
settings.timelineMode = TimeLineModeEnum.OnTop;
|
||||
this.saveSettings(settings);
|
||||
}
|
||||
|
||||
if(!settings.timelineHeader){
|
||||
settings.timelineHeader = TimeLineHeaderEnum.Title_DomainName;
|
||||
this.saveSettings(settings);
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
saveSettings(settings: GlobalSettings) {
|
||||
this.store.dispatch([
|
||||
new SaveSettings(settings)
|
||||
]);
|
||||
}
|
||||
|
||||
saveContentWarningPolicy(cwSettings: ContentWarningPolicy) {
|
||||
this.store.dispatch([
|
||||
new SaveContentWarningPolicy(cwSettings)
|
||||
]);
|
||||
}
|
||||
|
||||
findAccount(account: AccountInfo, accountName: string): Promise<Account> {
|
||||
let findAccountFunc = (result: Results) => {
|
||||
if (accountName[0] === '@') accountName = accountName.substr(1);
|
||||
|
@ -7,9 +7,9 @@ import { Status, Notification } from './models/mastodon.interfaces';
|
||||
import { MastodonWrapperService } from './mastodon-wrapper.service';
|
||||
import { AccountInfo } from '../states/accounts.state';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { ToolsService } from './tools.service';
|
||||
import { StreamingService, StatusUpdate, EventEnum } from './streaming.service';
|
||||
import { StreamElement, StreamTypeEnum } from '../states/streams.state';
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
@ -29,8 +29,8 @@ export class UserNotificationService {
|
||||
private loadedAccounts: AccountInfo[] = [];
|
||||
|
||||
constructor(
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly streamingService: StreamingService,
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly mastodonService: MastodonWrapperService,
|
||||
private readonly store: Store) {
|
||||
@ -89,7 +89,7 @@ export class UserNotificationService {
|
||||
}
|
||||
|
||||
private playSoundNotification() {
|
||||
const settings = this.toolsService.getSettings();
|
||||
const settings = this.settingsService.getSettings();
|
||||
if (settings.disableSounds) return;
|
||||
if (this.soundJustPlayed) return;
|
||||
this.soundJustPlayed = true;
|
||||
@ -103,13 +103,13 @@ export class UserNotificationService {
|
||||
}
|
||||
|
||||
private setNotificationSound() {
|
||||
let settings = this.toolsService.getSettings();
|
||||
let settings = this.settingsService.getSettings();
|
||||
let soundId = settings.notificationSoundFileId;
|
||||
|
||||
if (!soundId) {
|
||||
soundId = '0';
|
||||
settings.notificationSoundFileId = '0';
|
||||
this.toolsService.saveSettings(settings);
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
if (this.soundFileId === soundId) return;
|
||||
@ -174,7 +174,7 @@ export class UserNotificationService {
|
||||
|
||||
let lastNotificationId = newNotifications[newNotifications.length - 1].id;
|
||||
|
||||
const accountSettings = this.toolsService.getAccountSettings(account);
|
||||
const accountSettings = this.settingsService.getAccountSettings(account);
|
||||
|
||||
if (type === NotificationTypeEnum.UserMention) {
|
||||
userNotification.lastMentionsId = lastNotificationId;
|
||||
@ -190,12 +190,12 @@ export class UserNotificationService {
|
||||
// Set settings if needed
|
||||
if (type === NotificationTypeEnum.UserMention && !accountSettings.lastMentionCreationDate && newNotifications.length > 0) {
|
||||
accountSettings.lastMentionCreationDate = newNotifications[0].created_at;
|
||||
this.toolsService.saveAccountSettings(accountSettings);
|
||||
this.settingsService.saveAccountSettings(accountSettings);
|
||||
}
|
||||
|
||||
if (type === NotificationTypeEnum.UserNotification && !accountSettings.lastNotificationCreationDate && newNotifications.length > 0) {
|
||||
accountSettings.lastNotificationCreationDate = newNotifications[0].created_at;
|
||||
this.toolsService.saveAccountSettings(accountSettings);
|
||||
this.settingsService.saveAccountSettings(accountSettings);
|
||||
}
|
||||
|
||||
return userNotification;
|
||||
@ -208,10 +208,10 @@ export class UserNotificationService {
|
||||
const lastMention = currentAccountNotifications.mentions[0];
|
||||
|
||||
if (lastMention) {
|
||||
const settings = this.toolsService.getAccountSettings(account);
|
||||
const settings = this.settingsService.getAccountSettings(account);
|
||||
// const lastMentionNotification = currentAccountNotifications.mentions[0];
|
||||
settings.lastMentionCreationDate = lastMention.created_at;
|
||||
this.toolsService.saveAccountSettings(settings);
|
||||
this.settingsService.saveAccountSettings(settings);
|
||||
}
|
||||
|
||||
if (currentAccountNotifications.hasNewMentions === true) {
|
||||
@ -226,9 +226,9 @@ export class UserNotificationService {
|
||||
|
||||
const lastNotification = currentAccountNotifications.notifications[0];
|
||||
if (lastNotification) {
|
||||
const settings = this.toolsService.getAccountSettings(account);
|
||||
const settings = this.settingsService.getAccountSettings(account);
|
||||
settings.lastNotificationCreationDate = lastNotification.created_at;
|
||||
this.toolsService.saveAccountSettings(settings);
|
||||
this.settingsService.saveAccountSettings(settings);
|
||||
}
|
||||
|
||||
if (currentAccountNotifications.hasNewNotifications === true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user