diff --git a/src/app/components/create-status/create-status.component.ts b/src/app/components/create-status/create-status.component.ts
index 2561159a..1611a42e 100644
--- a/src/app/components/create-status/create-status.component.ts
+++ b/src/app/components/create-status/create-status.component.ts
@@ -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);
diff --git a/src/app/components/floating-column/manage-account/manage-account.component.ts b/src/app/components/floating-column/manage-account/manage-account.component.ts
index 0a844900..0be3c500 100644
--- a/src/app/components/floating-column/manage-account/manage-account.component.ts
+++ b/src/app/components/floating-column/manage-account/manage-account.component.ts
@@ -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) {
diff --git a/src/app/components/floating-column/manage-account/my-account/list-editor/list-editor.component.ts b/src/app/components/floating-column/manage-account/my-account/list-editor/list-editor.component.ts
index f6cb4e04..a959223c 100644
--- a/src/app/components/floating-column/manage-account/my-account/list-editor/list-editor.component.ts
+++ b/src/app/components/floating-column/manage-account/my-account/list-editor/list-editor.component.ts
@@ -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 { of } from 'rxjs';
+import { SettingsService } from '../../../../../services/settings.service';
@Component({
selector: 'app-list-editor',
@@ -25,6 +25,7 @@ export class ListEditorComponent implements OnInit {
searchOpen: boolean;
constructor(
+ private readonly settingsService: SettingsService,
private readonly notificationService: NotificationService,
private readonly mastodonService: MastodonWrapperService) { }
@@ -69,13 +70,12 @@ export class ListEditorComponent implements OnInit {
}
addEvent(accountWrapper: AccountListWrapper) {
- console.log(accountWrapper);
+ const settings = this.settingsService.getSettings();
accountWrapper.isLoading = true;
this.mastodonService.getInstance(this.account.info.instance)
.then((instance: Instance) => {
- console.log(instance);
- if (instance.version.toLowerCase().includes('pleroma')) {
+ if (instance.version.toLowerCase().includes('pleroma') && !settings.autoFollowOnListEnabled) {
return Promise.resolve(true);
} else {
return this.followAccount(accountWrapper);
diff --git a/src/app/components/floating-column/manage-account/my-account/my-account.component.ts b/src/app/components/floating-column/manage-account/my-account/my-account.component.ts
index c888fb90..58710d92 100644
--- a/src/app/components/floating-column/manage-account/my-account/my-account.component.ts
+++ b/src/app/components/floating-column/manage-account/my-account/my-account.component.ts
@@ -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);
}
}
diff --git a/src/app/components/floating-column/settings/settings.component.html b/src/app/components/floating-column/settings/settings.component.html
index 01df4b0f..f6e0efb9 100644
--- a/src/app/components/floating-column/settings/settings.component.html
+++ b/src/app/components/floating-column/settings/settings.component.html
@@ -35,6 +35,7 @@
play
+
Shortcuts
switch column:
@@ -50,6 +51,21 @@
+ Twitter Bridge
+
+
+
+
+
+
Please provide your bridge instance:
+
+ If you don't know any, consider using BirdsiteLIVE
+
+
+
Content-Warning Policies
global behavior:
@@ -135,6 +151,17 @@
+
+
Pleroma
+
+
+
+
+
+
+
Other
About
Sengi version: {{version}}
- open tutorial
- imprint & privacy
- check for updates
+ open tutorial
+ imprint & privacy
+ check for updates
diff --git a/src/app/components/floating-column/settings/settings.component.ts b/src/app/components/floating-column/settings/settings.component.ts
index 838135b3..7c364388 100644
--- a/src/app/components/floating-column/settings/settings.component.ts
+++ b/src/app/components/floating-column/settings/settings.component.ts
@@ -3,12 +3,13 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { Howl } from 'howler';
import { environment } from '../../../../environments/environment';
-import { ToolsService } from '../../../services/tools.service';
+import { ToolsService, InstanceType } from '../../../services/tools.service';
import { UserNotificationService, NotificationSoundDefinition } from '../../../services/user-notification.service';
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',
@@ -28,6 +29,11 @@ export class SettingsComponent implements OnInit {
disableSoundsEnabled: boolean;
version: string;
+ hasPleromaAccount: boolean;
+ autoFollowOnListEnabled: boolean;
+
+ twitterBridgeEnabled: boolean;
+
columnShortcutEnabled: ColumnShortcut = ColumnShortcut.Ctrl;
timeLineHeader: TimeLineHeaderEnum = TimeLineHeaderEnum.Title_DomainName;
timeLineMode: TimeLineModeEnum = TimeLineModeEnum.OnTop;
@@ -60,7 +66,18 @@ export class SettingsComponent implements OnInit {
return this.contentHidedCompletely;
}
+ private twitterBridgeInstance: string;
+ set setTwitterBridgeInstance(value: string) {
+ let instance = value.replace('https://', '').replace('http://', '').replace('/', '').trim();
+ this.setBridgeInstance(instance);
+ this.twitterBridgeInstance = instance;
+ }
+ get setTwitterBridgeInstance(): string {
+ return this.twitterBridgeInstance;
+ }
+
constructor(
+ private readonly settingsService: SettingsService,
private readonly navigationService: NavigationService,
private formBuilder: FormBuilder,
private serviceWorkersService: ServiceWorkerService,
@@ -71,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;
@@ -97,33 +114,48 @@ export class SettingsComponent implements OnInit {
this.timeLineHeader = settings.timelineHeader;
this.timeLineMode = settings.timelineMode;
+
+ this.autoFollowOnListEnabled = settings.autoFollowOnListEnabled;
+ const accs = this.toolsService.getAllAccounts();
+ accs.forEach(a => {
+ this.toolsService.getInstanceInfo(a)
+ .then(ins => {
+ if(ins.type === InstanceType.Pleroma){
+ this.hasPleromaAccount = true;
+ }
+ })
+ .catch(err => console.error(err));
+ });
+
+ this.twitterBridgeEnabled = settings.twitterBridgeEnabled;
+ this.twitterBridgeInstance = settings.twitterBridgeInstance;
}
onShortcutChange(id: ColumnShortcut) {
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) {
@@ -135,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){
@@ -162,13 +194,19 @@ export class SettingsComponent implements OnInit {
cwPolicySettings.hideCompletlyContent = settings.contentWarningPolicy.hideCompletlyContent;
}
- this.toolsService.saveContentWarningPolicy(cwPolicySettings);
- }
+ this.settingsService.saveContentWarningPolicy(cwPolicySettings);
+ }
private splitCwValues(data: string): string[]{
return data.split(';').map(x => x.trim().toLowerCase()).filter((value, index, self) => self.indexOf(value) === index).filter(y => y !== '');
}
+ private setBridgeInstance(instance: string){
+ let settings = this.settingsService.getSettings();
+ settings.twitterBridgeInstance = instance;
+ this.settingsService.saveSettings(settings);
+ }
+
// reload(): boolean {
// window.location.reload();
// return false;
@@ -176,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 {
@@ -194,29 +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.settingsService.getSettings();
+ settings.autoFollowOnListEnabled = this.autoFollowOnListEnabled;
+ this.settingsService.saveSettings(settings);
+ }
+
+ onTwitterBridgeEnabledChanged(){
+ let settings = this.settingsService.getSettings();
+ settings.twitterBridgeEnabled = this.twitterBridgeEnabled;
+ this.settingsService.saveSettings(settings);
}
isCleanningAll: boolean = false;
diff --git a/src/app/components/left-side-bar/left-side-bar.component.ts b/src/app/components/left-side-bar/left-side-bar.component.ts
index 37398357..e729d2b4 100644
--- a/src/app/components/left-side-bar/left-side-bar.component.ts
+++ b/src/app/components/left-side-bar/left-side-bar.component.ts
@@ -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);
diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.ts b/src/app/components/stream/stream-statuses/stream-statuses.component.ts
index fe8559a0..64d01f45 100644
--- a/src/app/components/stream/stream-statuses/stream-statuses.component.ts
+++ b/src/app/components/stream/stream-statuses/stream-statuses.component.ts
@@ -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
;
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(() => {
diff --git a/src/app/components/stream/stream.component.ts b/src/app/components/stream/stream.component.ts
index bb7850e1..43d7f292 100644
--- a/src/app/components/stream/stream.component.ts
+++ b/src/app/components/stream/stream.component.ts
@@ -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;
}
diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts
index 844d2d74..5bb89e22 100644
--- a/src/app/components/stream/thread/thread.component.ts
+++ b/src/app/components/stream/thread/thread.component.ts
@@ -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) {
diff --git a/src/app/components/streams-selection-footer/streams-selection-footer.component.ts b/src/app/components/streams-selection-footer/streams-selection-footer.component.ts
index a6dd36b3..77b864a4 100644
--- a/src/app/components/streams-selection-footer/streams-selection-footer.component.ts
+++ b/src/app/components/streams-selection-footer/streams-selection-footer.component.ts
@@ -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;
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();
diff --git a/src/app/services/mastodon-wrapper.service.ts b/src/app/services/mastodon-wrapper.service.ts
index 9452ced7..63e0b689 100644
--- a/src/app/services/mastodon-wrapper.service.ts
+++ b/src/app/services/mastodon-wrapper.service.ts
@@ -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 } = {};
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 {
+ 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 {
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 {
+ 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);
diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts
new file mode 100644
index 00000000..b0727fa5
--- /dev/null
+++ b/src/app/services/settings.service.ts
@@ -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 = this.store.snapshot().globalsettings.settings;
+
+ if (!settings.contentWarningPolicy) {
+ var newCwPolicy = new ContentWarningPolicy();
+ this.saveContentWarningPolicy(newCwPolicy);
+ return 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 = 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)
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/src/app/services/tools.service.ts b/src/app/services/tools.service.ts
index 001d9912..a6eaa891 100644
--- a/src/app/services/tools.service.ts
+++ b/src/app/services/tools.service.ts
@@ -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 = 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 = this.store.snapshot().globalsettings.settings;
-
- if (!settings.contentWarningPolicy) {
- var newCwPolicy = new ContentWarningPolicy();
- this.saveContentWarningPolicy(newCwPolicy);
- return 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 {
let findAccountFunc = (result: Results) => {
if (accountName[0] === '@') accountName = accountName.substr(1);
diff --git a/src/app/services/user-notification.service.ts b/src/app/services/user-notification.service.ts
index 7110bafd..1c5b3a9a 100644
--- a/src/app/services/user-notification.service.ts
+++ b/src/app/services/user-notification.service.ts
@@ -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) {
diff --git a/src/app/states/settings.state.ts b/src/app/states/settings.state.ts
index 3b71a199..89f41a88 100644
--- a/src/app/states/settings.state.ts
+++ b/src/app/states/settings.state.ts
@@ -66,8 +66,11 @@ export class GlobalSettings {
disableAvatarNotifications = false;
disableSounds = false;
disableRemoteStatusFetching = false;
+ autoFollowOnListEnabled = false;
+ twitterBridgeEnabled = false;
notificationSoundFileId: string = '0';
+ twitterBridgeInstance: string = '';
timelineHeader: TimeLineHeaderEnum = TimeLineHeaderEnum.Title_DomainName;
timelineMode: TimeLineModeEnum = TimeLineModeEnum.OnTop;
@@ -164,6 +167,9 @@ export class SettingsState {
newSettings.disableRemoteStatusFetching = oldSettings.disableRemoteStatusFetching;
newSettings.timelineHeader = oldSettings.timelineHeader;
newSettings.timelineMode = oldSettings.timelineMode;
+ newSettings.autoFollowOnListEnabled = oldSettings.autoFollowOnListEnabled;
+ newSettings.twitterBridgeEnabled = oldSettings.twitterBridgeEnabled;
+ newSettings.twitterBridgeInstance = oldSettings.twitterBridgeInstance;
return newSettings;
}