mirror of https://github.com/vector-im/riot-web
UserAddressType -> IUserAddress
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>pull/21833/head
parent
a747bbbae7
commit
93ab4dc787
|
@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import PropTypes from "prop-types";
|
|
||||||
|
|
||||||
const emailRegex = /^\S+@\S+\.\S+$/;
|
const emailRegex = /^\S+@\S+\.\S+$/;
|
||||||
const mxUserIdRegex = /^@\S+:\S+$/;
|
const mxUserIdRegex = /^@\S+:\S+$/;
|
||||||
const mxRoomIdRegex = /^!\S+:\S+$/;
|
const mxRoomIdRegex = /^!\S+:\S+$/;
|
||||||
|
@ -33,16 +31,16 @@ export enum AddressType {
|
||||||
// could be a third party identifier or a matrix ID)
|
// could be a third party identifier or a matrix ID)
|
||||||
// along with some additional information about the
|
// along with some additional information about the
|
||||||
// address / target.
|
// address / target.
|
||||||
export const UserAddressType = PropTypes.shape({
|
export interface IUserAddress {
|
||||||
addressType: PropTypes.oneOf(addressTypes).isRequired,
|
addressType: AddressType;
|
||||||
address: PropTypes.string.isRequired,
|
address: string;
|
||||||
displayName: PropTypes.string,
|
displayName?: string;
|
||||||
avatarMxc: PropTypes.string,
|
avatarMxc?: string;
|
||||||
// true if the address is known to be a valid address (eg. is a real
|
// true if the address is known to be a valid address (eg. is a real
|
||||||
// user we've seen) or false otherwise (eg. is just an address the
|
// user we've seen) or false otherwise (eg. is just an address the
|
||||||
// user has entered)
|
// user has entered)
|
||||||
isKnown: PropTypes.bool,
|
isKnown?: boolean;
|
||||||
});
|
}
|
||||||
|
|
||||||
export function getAddressType(inputText: string): AddressType | null {
|
export function getAddressType(inputText: string): AddressType | null {
|
||||||
if (emailRegex.test(inputText)) {
|
if (emailRegex.test(inputText)) {
|
||||||
|
|
Loading…
Reference in New Issue