Add toasts when t.me link is not found
This commit is contained in:
parent
cfd91e6a84
commit
30b52bc55f
@ -1882,7 +1882,7 @@ export default class ChatBubbles {
|
||||
}
|
||||
|
||||
this.appMessagesManager.getNewHistory(peerId, this.chat.threadId).then((historyStorage) => {
|
||||
if(!middleware()) {
|
||||
if(!middleware() || !historyStorage) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
@ -551,12 +551,14 @@ const lang = {
|
||||
"Yesterday": "yesterday",
|
||||
"LeaveAComment": "Leave a comment",
|
||||
"ViewInChat": "View in chat",
|
||||
"LinkNotFound": "Unfortunately, you can\'t access this message. You are not a member of the chat where it was posted.",
|
||||
|
||||
// * macos
|
||||
"AccountSettings.Filters": "Chat Folders",
|
||||
"AccountSettings.Notifications": "Notifications and Sounds",
|
||||
"AccountSettings.PrivacyAndSecurity": "Privacy and Security",
|
||||
"AccountSettings.Language": "Language",
|
||||
"Alert.UserDoesntExists": "Sorry, this user doesn't seem to exist.",
|
||||
"Appearance.Reset": "Reset to Defaults",
|
||||
"Bio.Description": "Any details such as age, occupation or city.\nExample: 23 y.o. designer from San Francisco",
|
||||
"Channel.UsernameAboutChannel": "People can share this link with others and can find your channel using Telegram search.",
|
||||
|
@ -700,6 +700,18 @@ export class AppChatsManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public resolveChannel(id: number) {
|
||||
return apiManager.invokeApiSingle('channels.getChannels', {
|
||||
id: [{
|
||||
_: 'inputChannel',
|
||||
channel_id: id,
|
||||
access_hash: '0'
|
||||
}]
|
||||
}).then(messagesChats => {
|
||||
this.saveApiChats(messagesChats.chats);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const appChatsManager = new AppChatsManager();
|
||||
|
@ -61,7 +61,7 @@ import PopupElement from '../../components/popups';
|
||||
import singleInstance from '../mtproto/singleInstance';
|
||||
import PopupStickers from '../../components/popups/stickers';
|
||||
import PopupJoinChatInvite from '../../components/popups/joinChatInvite';
|
||||
import { toast } from '../../components/toast';
|
||||
import { toast, toastNew } from '../../components/toast';
|
||||
import debounce from '../../helpers/schedulers/debounce';
|
||||
import { pause } from '../../helpers/schedulers/pause';
|
||||
import appMessagesIdsManager from './appMessagesIdsManager';
|
||||
@ -328,12 +328,23 @@ export class AppImManager {
|
||||
uriParams: {thread?: number} | {comment?: number}
|
||||
}>({
|
||||
name: 'im',
|
||||
callback: (params) => {
|
||||
callback: async(params) => {
|
||||
console.log(params);
|
||||
|
||||
const {pathnameParams, uriParams} = params;
|
||||
if(pathnameParams[0] === 'c') {
|
||||
const peerId = -+pathnameParams[1];
|
||||
|
||||
const chat = appChatsManager.getChat(-peerId);
|
||||
if(chat.deleted) {
|
||||
try {
|
||||
await appChatsManager.resolveChannel(-peerId);
|
||||
} catch(err) {
|
||||
toastNew({langPackKey: 'LinkNotFound'});
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const postId = appMessagesIdsManager.generateMessageId(+pathnameParams[2]);
|
||||
const threadId = 'thread' in uriParams ? appMessagesIdsManager.generateMessageId(+uriParams.thread) : undefined;
|
||||
|
||||
@ -354,7 +365,7 @@ export class AppImManager {
|
||||
|
||||
private addAnchorListener<Params extends {pathnameParams?: any, uriParams?: any}>(options: {
|
||||
name: 'showMaskedAlert' | 'execBotCommand' | 'searchByHashtag' | 'addstickers' | 'joinchat' | 'im',
|
||||
callback: (params: Params, element: HTMLAnchorElement) => boolean | void,
|
||||
callback: (params: Params, element: HTMLAnchorElement) => boolean | any,
|
||||
parsePathname?: boolean,
|
||||
parseUriParams?: boolean,
|
||||
}) {
|
||||
@ -424,7 +435,9 @@ export class AppImManager {
|
||||
else return this.setInnerPeer(peerId, msgId);
|
||||
}, (err) => {
|
||||
if(err.type === 'USERNAME_NOT_OCCUPIED') {
|
||||
toast(i18n('NoUsernameFound'));
|
||||
toastNew({langPackKey: 'NoUsernameFound'});
|
||||
} else if(err.type === 'USERNAME_INVALID') {
|
||||
toastNew({langPackKey: 'Alert.UserDoesntExists'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user